Jump to content


fir12 help


  • You cannot reply to this topic
3 replies to this topic

#1 ureyhu

    Member

  • Members
  • PipPip
  • 8 posts

Posted 27 December 2009 - 08:15 PM

hello everybody, I'm a freshman in ImpulseC and I found something wierd in the basic examples fir12 provided by ImpulseC . ( .. \Impulse\CoDeveloper3\Examples\DSP\fir12 ).
After I compile the project , I try to run the Fir12.exe file. However , the result is unexpected . The source file "filter_in.wav" (23.5kb) had merely been read and filtered for several times .the written result in "filter_out.wav" is only 317Bytes. When I try to debug it at the Visul studio 2008 IDE, I got the same result.

#2 etrexel

    Advanced Member

  • Impulse Staff
  • PipPipPip
  • 260 posts

Posted 28 December 2009 - 02:45 PM

QUOTE (ureyhu @ Dec 27 2009, 09:15 PM) <{POST_SNAPBACK}>
hello everybody, I'm a freshman in ImpulseC and I found something wierd in the basic examples fir12 provided by ImpulseC . ( .. \Impulse\CoDeveloper3\Examples\DSP\fir12 ).
After I compile the project , I try to run the Fir12.exe file. However , the result is unexpected . The source file "filter_in.wav" (23.5kb) had merely been read and filtered for several times .the written result in "filter_out.wav" is only 317Bytes. When I try to debug it at the Visul studio 2008 IDE, I got the same result.


Hi,
It appears the short output file is due to the mode in which the input file was opened. Please try the attached file after downloading it and renaming it to "fir_sw.c" in the Fir12 project.

Best Regards,
Ed

Attached File(s)


Ed Trexel
Impulse Accelerated Technologies, Inc.

#3 ureyhu

    Member

  • Members
  • PipPip
  • 8 posts

Posted 28 December 2009 - 05:40 PM

QUOTE (etrexel @ Dec 28 2009, 02:45 PM) <{POST_SNAPBACK}>
Hi,
It appears the short output file is due to the mode in which the input file was opened. Please try the attached file after downloading it and renaming it to "fir_sw.c" in the Fir12 project.

Best Regards,
Ed


Thanks very much , Ed.
What you said is right and the problem is retified . It seems that the problem is really due to it "inFile = fopen(FileName, "rb");"
The omission of "b" cause such a bother . The "r" mode mean read only ascii opened and "rb" is binary opened . So what's difference between "r " and "rb" causing something above.
With Best Regard.

#4 etrexel

    Advanced Member

  • Impulse Staff
  • PipPipPip
  • 260 posts

Posted 29 December 2009 - 07:35 AM

QUOTE (ureyhu @ Dec 28 2009, 06:40 PM) <{POST_SNAPBACK}>
Thanks very much , Ed.
What you said is right and the problem is retified . It seems that the problem is really due to it "inFile = fopen(FileName, "rb");"
The omission of "b" cause such a bother . The "r" mode mean read only ascii opened and "rb" is binary opened . So what's difference between "r " and "rb" causing something above.
With Best Regard.


Hi,
Opening a file using "r" mode opens it as a text/ASCII file while "rb" mode opens it as a binary file and a .wav file is binary. Text vs. binary may affect (depends on libraries, OS, etc.) how getc() views the data where text mode may include special handling of end-of-line while binary mode is more literal in reading characters one-by-one. Technically, for binary the use of fread() and fwrite() instead of getc(0 and putc() in the example may have been a better choice.

Best Regards,
Ed
Ed Trexel
Impulse Accelerated Technologies, Inc.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users