3
* Copyright 1991 Lance Norskog And Sundry Contributors
4
* This source code is freely redistributable and may be used for
5
* any purpose. This copyright notice must be maintained.
6
* Lance Norskog And Sundry Contributors are not responsible for
7
* the consequences of using this software.
23
* Incorporate Jimen Ching's fixes for real library operation: Aug 3, 1994.
24
* Redo all work from scratch, unfortunately.
25
* Separate out all common variables used by effects & handlers,
26
* and utility routines for other main programs to use.
30
/* FIXME: To be moved inside of fileop structure per handler. */
31
int verbose = 0; /* be noisy on stderr */
33
/* FIXME: These functions are user level concepts. Move them outside
39
st_report(const char *fmt, ...)
46
fprintf(stderr, "%s: ", myname);
48
vfprintf(stderr, fmt, args);
50
fprintf(stderr, "\n");
55
st_warn(const char *fmt, ...)
59
fprintf(stderr, "%s: ", myname);
62
vfprintf(stderr, fmt, args);
64
fprintf(stderr, "\n");
68
st_fail(const char *fmt, ...)
72
fprintf(stderr, "%s: ", myname);
75
vfprintf(stderr, fmt, args);
77
fprintf(stderr, "\n");
82
/* Warning: no error checking is done with errstr. Be sure not to
83
* go over the array limit ourself!
86
st_fail_errno(ft_t ft, int st_errno, const char *fmt, ...)
90
ft->st_errno = st_errno;
93
vsprintf(ft->st_errstr, fmt, args);
97
int st_is_bigendian(void)
110
int st_is_littleendian(void)
123
int strcmpcase(s1, s2)
126
while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
132
* File format routines
135
void st_copyformat(ft, ft2)
141
if (ft2->info.rate == 0) {
142
ft2->info.rate = ft->info.rate;
145
if (ft2->info.size == -1) {
146
ft2->info.size = ft->info.size;
149
if (ft2->info.encoding == -1) {
150
ft2->info.encoding = ft->info.encoding;
153
if (ft2->info.channels == -1) {
154
ft2->info.channels = ft->info.channels;
157
if (ft2->comment == NULL) {
158
ft2->comment = ft->comment;
162
* copy loop info, resizing appropriately
163
* it's in samples, so # channels don't matter
165
factor = (double) ft2->info.rate / (double) ft->info.rate;
166
for(i = 0; i < ST_MAX_NLOOPS; i++) {
167
ft2->loops[i].start = ft->loops[i].start * factor;
168
ft2->loops[i].length = ft->loops[i].length * factor;
169
ft2->loops[i].count = ft->loops[i].count;
170
ft2->loops[i].type = ft->loops[i].type;
172
/* leave SMPTE # alone since it's absolute */
173
ft2->instr = ft->instr;
176
void st_cmpformats(ft, ft2)
181
/* check that all settings have been given */
182
void st_checkformat(ft)
185
if (ft->info.rate == 0)
186
st_fail("Sampling rate for %s file was not given\n", ft->filename);
187
if ((ft->info.rate < 100) || (ft->info.rate > 999999L))
188
st_fail("Sampling rate %lu for %s file is bogus\n",
189
ft->info.rate, ft->filename);
190
if (ft->info.size == -1)
191
st_fail("Data size was not given for %s file\nUse one of -b/-w/-l/-f/-d/-D", ft->filename);
192
if (ft->info.encoding == -1 && ft->info.size != ST_SIZE_FLOAT)
193
st_fail("Data encoding was not given for %s file\nUse one of -s/-u/-U/-A", ft->filename);
194
/* it's so common, might as well default */
195
if (ft->info.channels == -1)
196
ft->info.channels = 1;
197
/* st_fail("Number of output channels was not given for %s file",
201
static ft_t ft_queue[2];
209
ft_queue[0]->file.eof = 1;
211
ft_queue[1]->file.eof = 1;
219
if (ft_queue[0] == 0)
223
signal(SIGINT, sigint);