r.stiltskin, on 12 March 2011 - 11:06 AM, said:
My answer is still basically the same:
But that doesn't make sense to me. You say that you are generating a new wave, so why are you reading the data of the old wave and writing the same data to the output file?
I also don't understand what you are doing with seekg. After each 4-byte read, the file pointer automatically advances 4 bytes. Isn't your data contiguous? Did you write something else in between the wave points that you want to skip over? What is s? Why are you moving the pointer?
edit: If you have a reason to skip some of the points from the input file, that's fine.
while(in.read(reinterpret_cast<char*>(&cos),sizeof (int))) will read and enter the loop only as long as there is more data in the file. It won't duplicate the last entry.
while(in.read(reinterpret_cast<char*>(&cos),sizeof (int))) {
out.write(reinterpret_cast<char*>(&cos),sizeof (int));
}
But that doesn't make sense to me. You say that you are generating a new wave, so why are you reading the data of the old wave and writing the same data to the output file?
I also don't understand what you are doing with seekg. After each 4-byte read, the file pointer automatically advances 4 bytes. Isn't your data contiguous? Did you write something else in between the wave points that you want to skip over? What is s? Why are you moving the pointer?
edit: If you have a reason to skip some of the points from the input file, that's fine.
while(in.read(reinterpret_cast<char*>(&cos),sizeof (int))) will read and enter the loop only as long as there is more data in the file. It won't duplicate the last entry.
i read it from file because later i will use the same code idea with DSP "TMS320C6000"
so i cant generate cosine wave and using the COS function but i have a table to read the wanted values from it "table lock up method "






MultiQuote




|