forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help writing a wav file into memory stick

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
PeterLeRoi



Joined: 16 May 2007
Posts: 31

PostPosted: Sat Jun 30, 2007 10:07 pm    Post subject: Help writing a wav file into memory stick Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Jul 01, 2007 4:28 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PeterLeRoi



Joined: 16 May 2007
Posts: 31

PostPosted: Sun Jul 01, 2007 12:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Jul 01, 2007 3:02 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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