|
-
December 14th, 2006, 06:18 AM
#1
F read type problem
Hello,
I am trying to read in values from a wav file. Each sample is 16 bits long (eg equivalent to a short int).
I want to run a FFT routine on the values then which takes a double array.
When I try to read in the values from the wav file with fread straight to the double array (with the code)
Code:
fread(sound_buffer, 2, 512, WavFile);
it puts two samples into each element of the double array sound_buffer as (presumably) each element is 32 bits and each sample is only 16 bits long.
This means that the values in the double array are useless.
I have it working by first f reading the values into a short int array then copying them into a double array but this is hugely ineffecient as it's going to be called a few hundred times a second.
Does anyone know how to use fread to copy one short int to every double element in the array?
Thanks a million,
Conor.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|