![]() |
|
#1
|
|||
|
|||
Error: Broken Pipehai,
i got one problem during fread on wave file.. i found the error message as follows "Broken Pipe". If any one know the reason for that error and how to recover from that error.. then please answer me |
|
#2
|
|||
|
|||
Re: hai any one help me...Quote:
Show us some code. Tell us about the .wav file. Did you print the values you read from the headers in the .wav file? Are the values consistent with the properties of the file you are reading? Regards, Dave |
|
#3
|
|||
|
|||
Re: hai any one help me...Quote:
My experience suggests that you've tried to read past the end of the file. :davis: |
|
#4
|
|||
|
|||
Re: hai any one help me...Quote:
hai.. i am attaching TEXT file that has code and comments and i mentioned where the problem i got and what the error message i found. Actually i used following code in conversion of PCM format data TRUESPEECH. But i got error while reading PCM format file.. Please go through the code and please help me.. i am awaiting for your reply. Regards Mahendra |
|
#5
|
|||
|
|||
Re: hai any one help me...hai..
I just read the wave file header (this is just to place file pointer after header 58/90 bytes).. i can replace fread with fseek.. then also no problem. I read the header data in to msg variable(see it in code).. i didnot used any where that header. after reading from 58/90 bytes that is data containing in file it is almost binary data.. here i am getting the error..... some cases it working fine some other cases it's not done proper reading.. i think my logic is good but it is the error thrown by the OS... what are the possible reasons? is my code help u while tracing the problem? CPP / C++ / C Code:
Last edited by admin : 07-Nov-2007 at 05:02.
Reason: Please insert your C/C++ example codes between [CPP] and [/CPP] tags
|
|
#6
|
|||
|
|||
Re: hai any one help me...Quote:
Quote:
Quote:
Regards, Dave |
|
#7
|
|||
|
|||
Re: hai any one help me...hai..
yaa i am openeing the file in binary mode and my application uses two versions of files PCM (MONO, 8khz, 8bit) this takes 58 bytes header size... and another one is TRUESPEECh (MONO, 8khz, 1bit) this takes 90 bytes header... so i provide these two file formats to my application then it will manage |
|
#8
|
|||
|
|||
Re: hai any one help me...Quote:
Program file: CPP / C++ / C Code:
Here's the header CPP / C++ / C Code:
Output Code:
You should be able to compile my program with any recent Microsoft or Borland or GNU C/C++ compiler. Try it. What does my program tell you about my .wav file? What does my program tell you about your .wav file? Does your program work with my .wav file? Regards, Dave Last edited by davekw7x : 08-Nov-2007 at 08:33.
|
|
#9
|
|||
|
|||
Re: Error: Broken PipeHai..
sorry for the delay. following output obtained when i used ur code for my wave file is there any thing wrong in that. OutPUT:: Size of Chunk Descriptor Header = 12 Size of Format SubChunk Header = 24 Size of Data SubChunk Header = 8 Number of bytes before samples = 44 Opened 100257.wav for reading ID from Chunk Descriptor Header: <RIFF> Size from Chunk Descriptor Header = 50 ID from Format SubChunk Headr: <fmt > Size = 18 Audio Format = 1 Number of channels = 1 Sample rate = 8000 Byte rate = 8000 Block Align = 1 Bits per sample = 8 ID from Data Subchunk Header: < 0x00 0x00 fa> Data Size = 291939 Samples per Channel = 291939 Now the file pointer is ready to read the data. Closed 100257.wav Number of files processed = 1 |
|
#10
|
||||||
|
||||||
Re: Error: Broken PipeQuote:
The idea was not for me to analyze your problem but to get you to do it. However... The following just make sure that the sizes of the variables and the packing of the structs are consistent with the rest if the program, and have nothing to do with the .wav file itself. Quote:
The following is calculated for a "classical" .wav file, and does not represent what is actually in the file. Quote:
The values are correct, so the program proceeds: Quote:
The "classical" .wav file has puts the file size minus eight bytes here. This also tells me where you got your 58-byte header size that I disagreed with. That doesn't mean that one of us is right and the other is wrong. It just means that we were talking about two different kinds of <RIFF> files. One is what I have been calling a "classical" .wav file and is described in the references that I gave you previously. According to the .wav format references that I use, for a "classical" .wav file the value of the size in the chunk descriptor header should be the total file size minus the eight bytes of the header. For example, the size of my "song.wav" file is 145481 bytes, and the value printed for that file is 145473. Quote:
Quote:
SInce your previous header was two bytes longer than mine, the two 0x00 bytes are actually part of the previous header and the first two bytes of this subchunk header are 'f', 'a'. Deducing the next two bytes from your output, it seems to me that the subchunk header bytes are 'f', 'a', 'c', 't' Here is a reference that tells you about the fact chunk http://www.sonicspot.com/guide/wavefiles.html#fact Now, the "fact" chunk is not required for uncompressed pcm, and my program doesn't take it into account, and I won't go any farther with it. It is perfectly "legal" to have a fmt chunk even in an uncompressed pcm file, but it's not part of the "classical" .wav file format. Bottom line: It is certainly possible for your program to process the file, regardless of whether it's a "classical" .wav file or one with a "fact" chunk. In either case you have to do some little work to get the correct file size so that you can get the correct buffer size to hold the data. From the reference above, about a "fact" chunk: "There is currently only one field defined for the format dependant data. It is a single 4-byte value that specifies the number of samples in the waveform data chunk." In your case, since it's a monaural 8-bit data file, the number of samples is equal to the number of bytes in the .wav part itself, so the 32-bit value following 'f','a','c','t' gives the number of data bytes in the file. (In general you have to multiply by the number of channels and the number of bytes per sample.) Since you have performed a read operation into a char array, I have to ask you how big is the array? In a previous post you indicated that you didn't use any information from the header. Regards, Dave Footnote: my simple program was used to get some information from a "classic" .wav file, and, as written, can't handle anything like a "fact" chunk. A more generic program could take such things into account. If you want to handle a specific type of file, you could specialize your program. In my opinion, you really must check the header information to make sure your program knows what it is dealing with. Last edited by davekw7x : 19-Nov-2007 at 09:37.
|
Recent GIDBlog
Flickr uploads of IA pictures by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The