#define ULAW #ifdef ULAW #include "../ulaw2linear.h" #endif /****************************************************************** * * DISKIO Version 49 * ****************************************************************** * * Handle I/O to sampled data (speech) files * * Uses FORTRAN sequential access, unformatted files with * signed 16 bit samples, 64 samples per record. * * DISKRD - Read speech from disk file * DISKWR - Write speech to disk file * CHAN - Channel number (1 to MAXC) * SPEECH - REAL buffer of samples (-1.0 to 1.0) * LENGTH - Number of samples to read or write * if ZERO, then close input or output file * EOF - If TRUE, end of file encountered on input * * DISKOP - Open a speech file for read or write * CHAN - Channel number (1 to MAXC) * FUNCTN - 0 for read, 1 for write * FNAME - File name * * DISKCL - Close a speech file * CHAN - Channel number (1 to MAXC) * * DISKFN - Get the filename of an open speech file * CHAN - Channel number (1 to MAXC) * FNAME - File name * FLEN - Number of characters in FNAME * * NOTE: Functions DISKOP and DISKCL are the preferred means * for opening and closing speech files. If DISKOP is not called * prior to DISKRD or DISKWR, the user is prompted for a filename. * DISKCL should be called for output files to ensure that the final * record is written. */ #include "lpcdefs.h" #define RECLEN 8192 #define maxc 4 #define rd 0 #define wr 1 diskio(which, chan, speech, length, eof, fname, functn) int which, length, functn; float *speech; char *fname; short *eof; FILE *chan; { int i,k; #ifdef ULAW unsigned char buf[RECLEN / 2]; #else short buf[RECLEN]; #endif #ifdef WUF short wuf[RECLEN]; #endif switch(which) { case 0: /****************************************************************** * Read From Input File *******************************************************************/ /* Input Samples */ k = fread(buf, sizeof(buf[0]), length, chan); if(k < length) *eof = END; for(i=0;i