home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
s
/
samsee.zip
/
SAMSEE.C
< prev
next >
Wrap
Text File
|
1993-01-09
|
2KB
|
95 lines
#include <stdio.h>
#include <math.h>
#include <graph.h>
#define X_MAX 640
#define Y_MAX 350
#define Y_DIV 2
#define X_RANGE (Y_DIV/2)
#define Y_RANGE 90
#define Y_START (Y_RANGE/2)
#define HLP_MSG "syntax... SAMSEE {sample filename}\n" \
"View .VOC .WAV and raw audio sample files.\n" \
"NOTE: requires EGA or VGA\n" \
"Press any key to exit.\n"
void seesam_exit( void );
void main( int argc, char * argv[] )
{
FILE *fp;
int ypos = 0, xpos = 0;
static unsigned char sample_byte[1];
int sub_val = 0;
char c;
if( NULL == argv[1] )
{
fprintf( stdout, "%s", HLP_MSG );
seesam_exit();
}
if( NULL == ( fp = fopen( argv[1], "rb" ) ) )
seesam_exit();
if( ! strcmp( "SAM", strupr( ( argv[1]+(strlen(argv[1])-3) ) ) ) )
sub_val = 128;
_setvideomode( _ERESCOLOR );
while(1)
{
for( ypos = Y_START; ypos < Y_MAX; ypos+=Y_RANGE+(Y_RANGE/4) )
{
/* draw red zero-line and reset begin of line position */
_moveto( 0, ypos );
_setcolor(4);
_lineto( 640, ypos );
/* lower limit line */
_moveto( 0, ypos-(Y_RANGE/Y_DIV) );
_setcolor(7);
_lineto( 640, ypos-(Y_RANGE/Y_DIV) );
/* upper limit line */
_moveto( 0, ypos+(Y_RANGE/Y_DIV) );
_setcolor(7);
_lineto( 640, ypos+(Y_RANGE/Y_DIV) );
_moveto( 0, ypos );
_setcolor(2);
for( xpos = 0; xpos < X_MAX; xpos+=X_RANGE )
{
fread( sample_byte, 1, 1, fp );
if( feof( fp ) )
seesam_exit();
sample_byte[0]+=sub_val;
_lineto( (int)xpos,
(int)( ( ( ( sample_byte[0] - 128 ) *
Y_RANGE / 256 + ypos ) ) ) );
}
}
c = getch();
if( '\x1b' == c )
{
fprintf( stdout, "Press any key to exit." );
break;
}
_clearscreen( _GCLEARSCREEN );
}
seesam_exit();
}
void seesam_exit( void )
{
getch();
_setvideomode( _DEFAULTMODE );
exit(0);
}