Definition at line 36 of file stereorize.c.
References argerrornum(), argerrortxt(), BUFFSIZE, channels, checknoargs(), errno, FALSE, fatalerror(), fatalperror(), free(), inform(), iswav, makewavheader(), malloc(), ME_NOOUTFILE, ME_NOTENOUGHFILES, ME_TOOMANYFILES, myexit(), NOCOMPLAIN, NOFILES, NULL, out, outfilename, parseargs(), parsefilearg(), readwavheader(), startstopwatch(), TRUE, Usage, usage, Version, version, and wavout.
38 int i, k[2], maxk, stdin_in_use=
FALSE;
39 short *leftsample, *rightsample, *stereosample;
41 char *filename[2], *tempname;
51 for (i = 0; i < 2; i++)
54 if (filename[i] ==
NULL)
56 if (strcmp (filename[i],
"-") == 0)
60 "Cannot use <stdin> for both input files");
61 filename[i] =
"<stdin>";
67 channel[i] = fopen(filename[i],
"rb");
69 if (channel[i] ==
NULL)
70 fatalerror(
"Error opening input file '%s': %s\n", filename[i],strerror(
errno));
72 inform(
"Using file '%s' as input\n", filename[i]);
74 for (i = 0; i < 2; i++)
76 assert ( channel[i] !=
NULL);
79 inform(
"Warning: '%s' is no mono file\n", filename[i]);
106 if (leftsample ==
NULL || rightsample ==
NULL || stereosample ==
NULL)
112 if ((strcmp(
outfilename,
"<stdout>")!=0) && (fseek(
out, 0, SEEK_SET) != 0))
121 for (i = 0; i < 2; i++)
123 k[i] = fread(i==0? leftsample : rightsample,
128 fatalerror(
"Error reading file '%s': %s\n", filename[i],strerror(
errno));
138 for (i = 0; i < k[0]; i++)
139 stereosample[2 * i] = leftsample[i];
143 for (; i < maxk; i++)
144 stereosample[2 * i] = 0;
149 for (i = 0; i < k[1]; i++)
150 stereosample[2 * i + 1] = rightsample[i];
154 for (; i < maxk; i++)
155 stereosample[2 * i + 1] = 0;
157 if (!fwrite(stereosample,
sizeof(*leftsample), 2 * maxk,
out)) {
158 fatalerror(
"Error writing to file '%s': %s\n",
void fatalperror(const char *string)
void parseargs(int argcount, char *args[], int fileswitch)
void startstopwatch(void)
int inform(const char *format,...)
void fatalerror(const char *format,...)
static struct channel_usage channels
static char version[AST_MAX_EXTENSION]
void argerrortxt(char *s, char *message)
void readwavheader(FILE *anyin)
void argerrornum(char *s, Errornum code)
void checknoargs(int argcount, char *args[])
char * parsefilearg(int argcount, char *args[])