home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sound Sensations!
/
sound_sensations.iso
/
miditool
/
dac12x16
/
16to12.c
next >
Wrap
C/C++ Source or Header
|
1988-05-21
|
501b
|
22 lines
/* 16to12--float to short for 12-bit DAC
* 16to12 < infile > outfile
*/
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define DAC12 2047 /* 2^12 / 2 - 1 */
#define DAC16 32767 /* 2^16 / 2 - 1 */
main()
{
short x;
short y;
setmode(fileno(stdin), O_BINARY);
setmode(fileno(stdout), O_BINARY);
while (fread((char *)&x, sizeof(short), 1, stdin))
{ y = (float)x / DAC16 * DAC12;
fwrite((char *)&y, sizeof(short), 1, stdout);
}
}