 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
PeterLeRoi
Joined: 16 May 2007 Posts: 31
|
Posted: Sat Jun 30, 2007 10:07 pm Post subject: Help writing a wav file into memory stick |
|
|
I need to write the header first, and second the data. The program I´m using:
| Code: |
void GrabaWAV(char *name,int size){
int tamanno = size;
int tamannoHeader = size + 36;
int sstg = sceIoOpen(name, PSP_O_WRONLY | PSP_O_CREAT , 0777);
printf("\nDescriptor abierto. Size = %d\n", size);
sceIoWrite(sstg, "RIFF",4*sizeof(char));
sceIoWrite(sstg, &tamannoHeader,sizeof(int));
sceIoWrite(sstg, "WAVE",4*sizeof(char));
printf("RIFF chunk descriptor escrito\n");
sceIoWrite(sstg, "fmt ",4*sizeof(char));
sceIoWrite(sstg, "16",sizeof(int));
sceIoWrite(sstg, "1",sizeof(short));
sceIoWrite(sstg, "1",sizeof(short));
sceIoWrite(sstg, "44100",sizeof(int));
sceIoWrite(sstg, "88200",sizeof(int));
sceIoWrite(sstg, "2",sizeof(short));
sceIoWrite(sstg, "16",sizeof(short));
printf("fmt sub-chunk descriptor escrito\n");
sceIoWrite(sstg, "data",4*sizeof(char));
sceIoWrite(sstg, &tamanno,sizeof(int));
printf("data sub-chunk descriptor escrito\n");
sceIoWrite(sstg, bigbuffer, &tamanno);
printf("Datos escritos\n");
sceIoClose(sstg);
}//GrabaWAV
|
But it creates a wav file with 0kB, and can´t be opened. I think header is right, can´t find the problem...
Edit: Sorry, the program is correct. It was a problem with the memory stick |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Jul 01, 2007 4:28 am Post subject: |
|
|
Wow, your output code is really messed up. For example,
| Code: | sceIoWrite(sstg, "1",sizeof(short));
sceIoWrite(sstg, "44100",sizeof(int)); |
"1" is a string, not a short, and "44100" is a string, not an int. If you want to output shorts and ints, point to a short or an int, not a string. |
|
| Back to top |
|
 |
PeterLeRoi
Joined: 16 May 2007 Posts: 31
|
Posted: Sun Jul 01, 2007 12:16 pm Post subject: |
|
|
Yep, you´re right. But, for the wav header, need the "1" to have 2bytes (one short) and "44100" to have 4bytes (one int).
Anyway, thanks ;) |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Jul 01, 2007 3:02 pm Post subject: |
|
|
| PeterLeRoi wrote: | Yep, you´re right. But, for the wav header, need the "1" to have 2bytes (one short) and "44100" to have 4bytes (one int).
Anyway, thanks ;) |
Right, so what you wanted was something like this:
| Code: | short h1 = 1;
int h2 = 44100;
sceIoWrite(sstg, &h1,sizeof(short));
sceIoWrite(sstg, &h2,sizeof(int)); |
What you REALLY need to do is define the header as a struct, fill in all the fields, then use one write command to write the struct to the file. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|