Advertisement
Guest User

Sensei 2 - audio patch

a guest
Dec 25th, 2013
109
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include <sys/wait.h>
  6.  
  7.  
  8. typedef struct { char filename[12] ; int address;} test;
  9.  
  10. int main(void){
  11.  
  12. pid_t childPID;
  13.  
  14. FILE * fi;
  15. FILE * fo;
  16. FILE * ft;
  17.  
  18. test casa[4000];
  19. int dboffset[4000];
  20.  
  21. int i,j;
  22. int offset;
  23. int status;
  24.  
  25. fi=fopen("VOICE","r");
  26. fo=fopen("VOICE.out","w");
  27.  
  28. /*primero 2 bytes*/
  29. putc(getc(fi),fo);
  30. putc(getc(fi),fo);
  31.  
  32. fread(&casa,sizeof(test),4000,fi);
  33.  
  34. i=0;
  35.  
  36. do{
  37.   fwrite(&casa[i],sizeof(test),1,fo);
  38. } while (casa[i++].filename[0] != '\0');
  39.  
  40. fflush(fo);
  41.  
  42. i=-1;
  43. while (casa[++i].filename[0] != '\0'){
  44.  
  45. //printf("break");
  46. //getchar();
  47.  
  48.   lseek(fileno(fi), casa[i].address , SEEK_SET);
  49.   dboffset[i]=(int) ftell(fo);
  50.  
  51.   if ( fork() == 0){
  52. //    dup2( fileno(fo), STDOUT_FILENO);
  53.     dup2( fileno(fi), STDIN_FILENO);
  54.     execl( "/usr/bin/ffmpeg","/usr/bin/ffmpeg","-i", "-", "-y","/dev/shm/tmp.wav");
  55.   }
  56.   wait(&status);
  57.   ft=fopen("/dev/shm/tmp.wav","r");
  58.   while( EOF != (j=fgetc(ft)))
  59.     fputc(j,fo);
  60.   fclose(ft);
  61. }
  62. //offset de la linea en blanco
  63.   dboffset[i]=(int) ftell(fo);
  64.  
  65.  
  66. i=0;
  67.  
  68. do{
  69.   printf("dboffset %x\n", dboffset[i]);
  70.   offset=(size_t) &casa[i].address - (size_t) &casa + 2;
  71.   fflush(fo);
  72.   fseek(fo, offset, SEEK_SET);
  73.   fwrite(&(dboffset[i]),sizeof(int),1,fo);
  74. } while (casa[i++].filename[0] != '\0');
  75.  
  76. fclose(fi);
  77. fclose(fo);
  78.  
  79. rename("VOICE","VOICE.bk");
  80. rename("VOICE.out","VOICE");
  81. return 0;
  82. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement