ref: 0ea58225b89ddcb1e38e57b350df2ea4ccb7ed7b
parent: 1e4f76215b8d22020b844a3bba701194f9f7a508
author: rrt <rrt>
date: Wed Dec 27 10:03:00 EST 2006
Rename sox.c's file_options struct to file_info, and to avoid confusion rename various st_signalinfo struct elements of this and other structs to "signal" from "info".
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -158,10 +158,10 @@
st_readdw(ft, &(p->nsamples));
ft->length = p->nsamples;
- ft->info.channels = channels;
- ft->info.rate = rate;
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.channels = channels;
+ ft->signal.rate = rate;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_BYTE;
/* open files to channels */
p->ch[0] = ft->fp;
@@ -201,7 +201,7 @@
svx_t p = (svx_t ) ft->priv;
while (done < nsamp) {
- for (i = 0; i < ft->info.channels; i++) {
+ for (i = 0; i < ft->signal.channels; i++) {
/* FIXME: don't pass FILE pointers! */
datum = getc(p->ch[i]);
if (feof(p->ch[i]))
@@ -209,7 +209,7 @@
/* scale signed up to long's range */
*buf++ = ST_SIGNED_BYTE_TO_SAMPLE(datum,);
}
- done += ft->info.channels;
+ done += ft->signal.channels;
}
return done;
}
@@ -224,7 +224,7 @@
svx_t p = (svx_t ) ft->priv;
/* close channel files */
- for (i = 1; i < ft->info.channels; i++) {
+ for (i = 1; i < ft->signal.channels; i++) {
fclose (p->ch[i]);
}
return(ST_SUCCESS);
@@ -240,7 +240,7 @@
/* open channel output files */
p->ch[0] = ft->fp;
- for (i = 1; i < ft->info.channels; i++) {
+ for (i = 1; i < ft->signal.channels; i++) {
if ((p->ch[i] = tmpfile()) == NULL)
{
st_fail_errno(ft,errno,"Can't open channel output file");
@@ -249,8 +249,8 @@
}
/* write header (channel 0) */
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_BYTE;
p->nsamples = 0;
svxwriteheader(ft, p->nsamples);
@@ -271,12 +271,12 @@
p->nsamples += len;
while(done < len) {
- for (i = 0; i < ft->info.channels; i++) {
+ for (i = 0; i < ft->signal.channels; i++) {
datum = ST_SAMPLE_TO_SIGNED_BYTE(*buf++, ft->clippedCount);
/* FIXME: Needs to pass ft struct and not FILE */
putc(datum, p->ch[i]);
}
- done += ft->info.channels;
+ done += ft->signal.channels;
}
return (done);
}
@@ -294,7 +294,7 @@
/* append all channel pieces to channel 0 */
/* close temp files */
- for (i = 1; i < ft->info.channels; i++) {
+ for (i = 1; i < ft->signal.channels; i++) {
if (fseeko(p->ch[i], 0L, 0))
{
st_fail_errno (ft,errno,"Can't rewind channel output file %d",i);
@@ -338,10 +338,10 @@
st_writes(ft, "VHDR");
st_writedw(ft, 20); /* number of bytes to follow */
- st_writedw(ft, nsamples/ft->info.channels); /* samples, 1-shot */
+ st_writedw(ft, nsamples/ft->signal.channels); /* samples, 1-shot */
st_writedw(ft, 0); /* samples, repeat */
st_writedw(ft, 0); /* samples per repeat cycle */
- st_writew(ft, (int) ft->info.rate); /* samples per second */
+ st_writew(ft, (int) ft->signal.rate); /* samples per second */
st_writeb(ft,1); /* number of octabes */
st_writeb(ft,0); /* data compression (none) */
st_writew(ft,1); st_writew(ft,0); /* volume */
@@ -352,8 +352,8 @@
st_writes(ft, "CHAN");
st_writedw(ft, 4);
- st_writedw(ft, (ft->info.channels == 2) ? 6 :
- (ft->info.channels == 4) ? 15 : 2);
+ st_writedw(ft, (ft->signal.channels == 2) ? 6 :
+ (ft->signal.channels == 4) ? 15 : 2);
st_writes(ft, "BODY");
st_writedw(ft, nsamples); /* samples in file */
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -79,9 +79,9 @@
aiff_t aiff = (aiff_t ) ft->priv;
st_size_t new_offset, channel_block, alignment;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -94,7 +94,7 @@
ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
if (ft->st_errno == ST_SUCCESS)
- aiff->nsamples = ft->length - (new_offset / ft->info.size);
+ aiff->nsamples = ft->length - (new_offset / ft->signal.size);
return(ft->st_errno);
}
@@ -399,32 +399,32 @@
}
if (foundcomm) {
- ft->info.channels = channels;
- ft->info.rate = rate;
- if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2)
+ ft->signal.channels = channels;
+ ft->signal.rate = rate;
+ if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_SIGN2)
st_report("AIFF only supports signed data. Forcing to signed.");
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
if (bits <= 8)
{
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.size = ST_SIZE_BYTE;
if (bits < 8)
st_report("Forcing data size from %d bits to 8 bits",bits);
}
else if (bits <= 16)
{
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.size = ST_SIZE_WORD;
if (bits < 16)
st_report("Forcing data size from %d bits to 16 bits",bits);
}
else if (bits <= 24)
{
- ft->info.size = ST_SIZE_24BIT;
+ ft->signal.size = ST_SIZE_24BIT;
if (bits < 24)
st_report("Forcing data size from %d bits to 24 bits",bits);
}
else if (bits <= 32)
{
- ft->info.size = ST_SIZE_DWORD;
+ ft->signal.size = ST_SIZE_DWORD;
if (bits < 32)
st_report("Forcing data size from %d bits to 32 bits",bits);
}
@@ -434,10 +434,10 @@
return(ST_EOF);
}
} else {
- if ((ft->info.channels == 0)
- || (ft->info.rate == 0)
- || (ft->info.encoding == ST_ENCODING_UNKNOWN)
- || (ft->info.size == -1)) {
+ if ((ft->signal.channels == 0)
+ || (ft->signal.rate == 0)
+ || (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ || (ft->signal.size == -1)) {
st_report("You must specify # channels, sample rate, signed/unsigned,");
st_report("and 8/16 on the command line.");
st_fail_errno(ft,ST_EFMT,"Bogus AIFF file: no COMM section.");
@@ -446,13 +446,13 @@
}
- aiff->nsamples = ssndsize / ft->info.size;
+ aiff->nsamples = ssndsize / ft->signal.size;
/* Cope with 'sowt' CD tracks as read on Macs */
if (is_sowt)
{
aiff->nsamples -= 4;
- ft->info.swap_bytes = !ft->info.swap_bytes;
+ ft->signal.swap_bytes = !ft->signal.swap_bytes;
}
if (foundmark && !foundinstr)
@@ -694,16 +694,16 @@
return rc;
aiff->nsamples = 0;
- if ((ft->info.encoding == ST_ENCODING_ULAW ||
- ft->info.encoding == ST_ENCODING_ALAW) &&
- ft->info.size == ST_SIZE_BYTE) {
+ if ((ft->signal.encoding == ST_ENCODING_ULAW ||
+ ft->signal.encoding == ST_ENCODING_ALAW) &&
+ ft->signal.size == ST_SIZE_BYTE) {
st_report("expanding 8-bit u-law to signed 16 bits");
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
}
- if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_SIGN2)
st_report("AIFF only supports signed data. Forcing to signed.");
- ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
+ ft->signal.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
/* Compute the "very large number" so that a maximum number
of samples can be transmitted through a pipe without the
@@ -711,7 +711,7 @@
At 48 kHz, 16 bits stereo, this gives ~3 hours of music.
Sorry, the AIFF format does not provide for an "infinite"
number of samples. */
- return(aiffwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels)));
+ return(aiffwriteheader(ft, 0x7f000000L / (ft->signal.size*ft->signal.channels)));
}
static st_size_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
@@ -744,7 +744,7 @@
st_fail_errno(ft,errno,"can't rewind output file to rewrite AIFF header");
return(ST_EOF);
}
- return(aiffwriteheader(ft, aiff->nsamples / ft->info.channels));
+ return(aiffwriteheader(ft, aiff->nsamples / ft->signal.channels));
}
static int aiffwriteheader(ft_t ft, st_size_t nframes)
@@ -764,17 +764,17 @@
hsize += 8 /* INST hdr */ + 20; /* INST chunk */
}
- if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_BYTE)
+ if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_BYTE)
bits = 8;
- else if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_WORD)
+ else if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_WORD)
bits = 16;
- else if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_24BIT)
+ else if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_24BIT)
bits = 24;
- else if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_DWORD)
+ else if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_DWORD)
bits = 32;
else
{
@@ -799,7 +799,7 @@
st_writes(ft, "FORM"); /* IFF header */
/* file size */
- st_writedw(ft, hsize + nframes * ft->info.size * ft->info.channels);
+ st_writedw(ft, hsize + nframes * ft->signal.size * ft->signal.channels);
st_writes(ft, "AIFF"); /* File type */
/* Now we write the COMT comment chunk using the precomputed sizes */
@@ -829,10 +829,10 @@
/* COMM chunk -- describes encoding (and #frames) */
st_writes(ft, "COMM");
st_writedw(ft, 18); /* COMM chunk size */
- st_writew(ft, ft->info.channels); /* nchannels */
+ st_writew(ft, ft->signal.channels); /* nchannels */
st_writedw(ft, nframes); /* number of frames */
st_writew(ft, bits); /* sample width, in bits */
- write_ieee_extended(ft, (double)ft->info.rate);
+ write_ieee_extended(ft, (double)ft->signal.rate);
/* MARK chunk -- set markers */
if (ft->instr.nloops) {
@@ -883,7 +883,7 @@
/* SSND chunk -- describes data */
st_writes(ft, "SSND");
/* chunk size */
- st_writedw(ft, 8 + nframes * ft->info.channels * ft->info.size);
+ st_writedw(ft, 8 + nframes * ft->signal.channels * ft->signal.size);
st_writedw(ft, 0); /* offset */
st_writedw(ft, 0); /* block size */
return(ST_SUCCESS);
@@ -900,16 +900,16 @@
return rc;
aiff->nsamples = 0;
- if ((ft->info.encoding == ST_ENCODING_ULAW ||
- ft->info.encoding == ST_ENCODING_ALAW) &&
- ft->info.size == ST_SIZE_BYTE) {
+ if ((ft->signal.encoding == ST_ENCODING_ULAW ||
+ ft->signal.encoding == ST_ENCODING_ALAW) &&
+ ft->signal.size == ST_SIZE_BYTE) {
st_report("expanding 8-bit u-law to signed 16 bits");
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
}
- if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_SIGN2)
st_report("AIFC only supports signed data. Forcing to signed.");
- ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
+ ft->signal.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
/* Compute the "very large number" so that a maximum number
of samples can be transmitted through a pipe without the
@@ -917,7 +917,7 @@
At 48 kHz, 16 bits stereo, this gives ~3 hours of music.
Sorry, the AIFC format does not provide for an "infinite"
number of samples. */
- return(aifcwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels)));
+ return(aifcwriteheader(ft, 0x7f000000L / (ft->signal.size*ft->signal.channels)));
}
static int st_aifcstopwrite(ft_t ft)
@@ -942,7 +942,7 @@
st_fail_errno(ft,errno,"can't rewind output file to rewrite AIFC header");
return(ST_EOF);
}
- return(aifcwriteheader(ft, aiff->nsamples / ft->info.channels));
+ return(aifcwriteheader(ft, aiff->nsamples / ft->signal.channels));
}
static int aifcwriteheader(ft_t ft, st_size_t nframes)
@@ -952,17 +952,17 @@
8 /*SSND hdr*/ + 12 /*SSND chunk*/;
int bits = 0;
- if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_BYTE)
+ if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_BYTE)
bits = 8;
- else if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_WORD)
+ else if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_WORD)
bits = 16;
- else if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_24BIT)
+ else if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_24BIT)
bits = 24;
- else if (ft->info.encoding == ST_ENCODING_SIGN2 &&
- ft->info.size == ST_SIZE_DWORD)
+ else if (ft->signal.encoding == ST_ENCODING_SIGN2 &&
+ ft->signal.size == ST_SIZE_DWORD)
bits = 32;
else
{
@@ -972,7 +972,7 @@
st_writes(ft, "FORM"); /* IFF header */
/* file size */
- st_writedw(ft, hsize + nframes * ft->info.size * ft->info.channels);
+ st_writedw(ft, hsize + nframes * ft->signal.size * ft->signal.channels);
st_writes(ft, "AIFC"); /* File type */
/* FVER chunk */
@@ -983,10 +983,10 @@
/* COMM chunk -- describes encoding (and #frames) */
st_writes(ft, "COMM");
st_writedw(ft, 18+4+1+15); /* COMM chunk size */
- st_writew(ft, ft->info.channels); /* nchannels */
+ st_writew(ft, ft->signal.channels); /* nchannels */
st_writedw(ft, nframes); /* number of frames */
st_writew(ft, bits); /* sample width, in bits */
- write_ieee_extended(ft, (double)ft->info.rate);
+ write_ieee_extended(ft, (double)ft->signal.rate);
st_writes(ft, "NONE"); /*compression_type*/
st_writeb(ft, 14);
@@ -996,7 +996,7 @@
/* SSND chunk -- describes data */
st_writes(ft, "SSND");
/* chunk size */
- st_writedw(ft, 8 + nframes * ft->info.channels * ft->info.size);
+ st_writedw(ft, 8 + nframes * ft->signal.channels * ft->signal.size);
st_writedw(ft, 0); /* offset */
st_writedw(ft, 0); /* block size */
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -83,13 +83,13 @@
snd_pcm_hw_params_get_channels_min(hw_params, &min_chan);
snd_pcm_hw_params_get_channels_max(hw_params, &max_chan);
- if (ft->info.channels == 0)
- ft->info.channels = min_chan;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = min_chan;
else
- if (ft->info.channels > max_chan)
- ft->info.channels = max_chan;
- else if (ft->info.channels < min_chan)
- ft->info.channels = min_chan;
+ if (ft->signal.channels > max_chan)
+ ft->signal.channels = max_chan;
+ else if (ft->signal.channels < min_chan)
+ ft->signal.channels = min_chan;
if (snd_pcm_format_mask_malloc(&fmask) < 0)
goto open_error;
@@ -108,16 +108,16 @@
goto open_error;
}
- rate = ft->info.rate;
+ rate = ft->signal.rate;
snd_pcm_hw_params_get_rate_min(hw_params, &min_rate, &dir);
snd_pcm_hw_params_get_rate_max(hw_params, &max_rate, &dir);
rate = max(rate, min_rate);
rate = min(rate, max_rate);
- if (rate != ft->info.rate)
+ if (rate != ft->signal.rate)
{
- st_report("alsa: Hardware does not support %d. Forcing sample rate to %d.", ft->info.rate, rate);
- ft->info.rate = rate;
+ st_report("alsa: Hardware does not support %d. Forcing sample rate to %d.", ft->signal.rate, rate);
+ ft->signal.rate = rate;
}
dir = 0;
if ((err = snd_pcm_hw_params_set_rate_near(alsa->pcm_handle,
@@ -132,10 +132,10 @@
&rate,
&dir);
- if (rate != ft->info.rate)
+ if (rate != ft->signal.rate)
{
st_report("Could not set exact rate of %d. Approximating with %d",
- ft->info.rate, rate);
+ ft->signal.rate, rate);
}
snd_pcm_hw_params_get_rate(hw_params, &rate, &dir);
@@ -142,13 +142,13 @@
if ((err = snd_pcm_hw_params_set_channels(alsa->pcm_handle,
hw_params,
- ft->info.channels)) < 0)
+ ft->signal.channels)) < 0)
{
st_fail_errno(ft, ST_EPERM, "cannot set channel count");
goto open_error;
}
- buffer_size = (ST_BUFSIZ / sizeof(st_sample_t) / ft->info.channels);
+ buffer_size = (ST_BUFSIZ / sizeof(st_sample_t) / ft->signal.channels);
if (snd_pcm_hw_params_get_buffer_size_min(hw_params, &buffer_size_min) < 0)
{
@@ -224,7 +224,7 @@
goto open_error;
}
- alsa->buf_size = buffer_size * ft->info.size * ft->info.channels;
+ alsa->buf_size = buffer_size * ft->signal.size * ft->signal.channels;
alsa->buf = xmalloc(alsa->buf_size);
return (ST_SUCCESS);
@@ -327,9 +327,9 @@
alsa_priv_t alsa = (alsa_priv_t)ft->priv;
void (*read_buf)(st_sample_t *, char const *, st_size_t, char, st_size_t *) = 0;
- switch(ft->info.size) {
+ switch(ft->signal.size) {
case ST_SIZE_BYTE:
- switch(ft->info.encoding)
+ switch(ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
read_buf = st_sb_read_buf;
@@ -343,7 +343,7 @@
}
break;
case ST_SIZE_WORD:
- switch(ft->info.encoding)
+ switch(ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
read_buf = st_sw_read_buf;
@@ -362,8 +362,8 @@
}
/* Prevent overflow */
- if (nsamp > alsa->buf_size/ft->info.size)
- nsamp = (alsa->buf_size/ft->info.size);
+ if (nsamp > alsa->buf_size/ft->signal.size)
+ nsamp = (alsa->buf_size/ft->signal.size);
len = 0;
while (len < nsamp)
@@ -370,7 +370,7 @@
{
/* ALSA library takes "frame" counts. */
err = snd_pcm_readi(alsa->pcm_handle, alsa->buf,
- (nsamp-len)/ft->info.channels);
+ (nsamp-len)/ft->signal.channels);
if (err < 0)
{
if (xrun_recovery(alsa->pcm_handle, err) < 0)
@@ -381,8 +381,8 @@
}
else
{
- read_buf(buf+(len*sizeof(st_sample_t)), alsa->buf, err, ft->info.swap_bytes, &ft->clippedCount);
- len += err * ft->info.channels;
+ read_buf(buf+(len*sizeof(st_sample_t)), alsa->buf, err, ft->signal.swap_bytes, &ft->clippedCount);
+ len += err * ft->signal.channels;
}
}
@@ -447,9 +447,9 @@
alsa_priv_t alsa = (alsa_priv_t)ft->priv;
void (*write_buf)(char *, const st_sample_t *, st_size_t, char, st_size_t *) = 0;
- switch(ft->info.size) {
+ switch(ft->signal.size) {
case ST_SIZE_BYTE:
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
write_buf = st_sb_write_buf;
@@ -463,7 +463,7 @@
}
break;
case ST_SIZE_WORD:
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
write_buf = st_sw_write_buf;
@@ -485,19 +485,19 @@
int err;
st_size_t len;
- osamp = min(nsamp - done, alsa->buf_size / ft->info.size);
- write_buf(alsa->buf, buf, osamp, ft->info.swap_bytes, &ft->clippedCount);
+ osamp = min(nsamp - done, alsa->buf_size / ft->signal.size);
+ write_buf(alsa->buf, buf, osamp, ft->signal.swap_bytes, &ft->clippedCount);
buf += osamp;
for (len = 0; len < osamp;) {
err = snd_pcm_writei(alsa->pcm_handle,
- alsa->buf + (len * ft->info.size),
- (osamp - len) / ft->info.channels);
+ alsa->buf + (len * ft->signal.size),
+ (osamp - len) / ft->signal.channels);
if (err < 0 && xrun_recovery(alsa->pcm_handle, err) < 0) {
st_fail_errno(ft, ST_EPERM, "ALSA write error");
return 0;
} else
- len += err * ft->info.channels;
+ len += err * ft->signal.channels;
}
}
@@ -521,56 +521,56 @@
static int get_format(ft_t ft, snd_pcm_format_mask_t *fmask, int *fmt)
{
- if (ft->info.size == -1)
- ft->info.size = ST_SIZE_WORD;
+ if (ft->signal.size == -1)
+ ft->signal.size = ST_SIZE_WORD;
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
{
- if (ft->info.size == ST_SIZE_WORD)
- ft->info.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.size == ST_SIZE_WORD)
+ ft->signal.encoding = ST_ENCODING_SIGN2;
else
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
- if (ft->info.size != ST_SIZE_WORD &&
- ft->info.size != ST_SIZE_BYTE)
+ if (ft->signal.size != ST_SIZE_WORD &&
+ ft->signal.size != ST_SIZE_BYTE)
{
st_report("ALSA driver only supports byte and word samples. Changing to word.");
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.size = ST_SIZE_WORD;
}
- if (ft->info.encoding != ST_ENCODING_SIGN2 &&
- ft->info.encoding != ST_ENCODING_UNSIGNED)
+ if (ft->signal.encoding != ST_ENCODING_SIGN2 &&
+ ft->signal.encoding != ST_ENCODING_UNSIGNED)
{
- if (ft->info.size == ST_SIZE_WORD)
+ if (ft->signal.size == ST_SIZE_WORD)
{
st_report("ALSA driver only supports signed and unsigned samples. Changing to signed.");
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
else
{
st_report("ALSA driver only supports signed and unsigned samples. Changing to unsigned.");
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
}
/* Some hardware only wants to work with 8-bit or 16-bit data */
- if (ft->info.size == ST_SIZE_BYTE)
+ if (ft->signal.size == ST_SIZE_BYTE)
{
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U8)) &&
!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S8)))
{
st_report("ALSA driver doesn't supported byte samples. Changing to words.");
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.size = ST_SIZE_WORD;
}
}
- else if (ft->info.size == ST_SIZE_WORD)
+ else if (ft->signal.size == ST_SIZE_WORD)
{
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)) &&
!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
{
st_report("ALSA driver doesn't supported word samples. Changing to bytes.");
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.size = ST_SIZE_BYTE;
}
}
else
@@ -578,24 +578,24 @@
if ((snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)) ||
(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
{
- st_report("ALSA driver doesn't supported %s samples. Changing to words.", st_sizes_str[(unsigned char)ft->info.size]);
- ft->info.size = ST_SIZE_WORD;
+ st_report("ALSA driver doesn't supported %s samples. Changing to words.", st_sizes_str[(unsigned char)ft->signal.size]);
+ ft->signal.size = ST_SIZE_WORD;
}
else
{
- st_report("ALSA driver doesn't supported %s samples. Changing to bytes.", st_sizes_str[(unsigned char)ft->info.size]);
- ft->info.size = ST_SIZE_BYTE;
+ st_report("ALSA driver doesn't supported %s samples. Changing to bytes.", st_sizes_str[(unsigned char)ft->signal.size]);
+ ft->signal.size = ST_SIZE_BYTE;
}
}
- if (ft->info.size == ST_SIZE_BYTE) {
- switch (ft->info.encoding)
+ if (ft->signal.size == ST_SIZE_BYTE) {
+ switch (ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S8)))
{
st_report("ALSA driver doesn't supported signed byte samples. Changing to unsigned bytes.");
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
break;
case ST_ENCODING_UNSIGNED:
@@ -602,13 +602,13 @@
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U8)))
{
st_report("ALSA driver doesn't supported unsigned byte samples. Changing to signed bytes.");
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
break;
default:
break;
}
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S8)))
@@ -630,14 +630,14 @@
break;
}
}
- else if (ft->info.size == ST_SIZE_WORD) {
- switch (ft->info.encoding)
+ else if (ft->signal.size == ST_SIZE_WORD) {
+ switch (ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
{
st_report("ALSA driver does not support signed word samples. Changing to unsigned words.");
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
break;
case ST_ENCODING_UNSIGNED:
@@ -644,13 +644,13 @@
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)))
{
st_report("ALSA driver does not support unsigned word samples. Changing to signed words.");
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
break;
default:
break;
}
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_SIGN2:
if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
@@ -673,7 +673,7 @@
}
}
else {
- st_fail_errno(ft,ST_EFMT,EMSGFMT,st_encodings_str[(unsigned char)ft->info.encoding], st_sizes_str[(unsigned char)ft->info.size]);
+ st_fail_errno(ft,ST_EFMT,EMSGFMT,st_encodings_str[(unsigned char)ft->signal.encoding], st_sizes_str[(unsigned char)ft->signal.size]);
return ST_EOF;
}
return 0;
--- a/src/au.c
+++ b/src/au.c
@@ -119,9 +119,9 @@
{
st_size_t new_offset, channel_block, alignment;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -164,11 +164,11 @@
* left over from pre-standardize period of testing for
* endianess. Its not hurting though.
*/
- ft->info.swap_bytes = !ft->info.swap_bytes;
+ ft->signal.swap_bytes = !ft->signal.swap_bytes;
st_debug("Found inverted DEC magic word. Swapping bytes.");
}
else if (magic == SUN_INV_MAGIC) {
- ft->info.swap_bytes = !ft->info.swap_bytes;
+ ft->signal.swap_bytes = !ft->signal.swap_bytes;
st_debug("Found inverted Sun/NeXT magic word. Swapping bytes.");
}
else if (magic == SUN_MAGIC) {
@@ -203,8 +203,8 @@
p->dec_routine = NULL;
p->in_buffer = 0;
p->in_bits = 0;
- if(st_auencodingandsize(encoding, &(ft->info.encoding),
- &(ft->info.size)) == ST_EOF)
+ if(st_auencodingandsize(encoding, &(ft->signal.encoding),
+ &(ft->signal.size)) == ST_EOF)
{
st_fail_errno(ft,ST_EFMT,"Unsupported encoding in Sun/NeXT header.\nOnly U-law, signed bytes, signed words, ADPCM, and 32-bit floats are supported.");
return(ST_EOF);
@@ -230,15 +230,15 @@
/* Read the sampling rate */
st_readdw(ft, &sample_rate);
- if (ft->info.rate == 0 || ft->info.rate == sample_rate)
- ft->info.rate = sample_rate;
+ if (ft->signal.rate == 0 || ft->signal.rate == sample_rate)
+ ft->signal.rate = sample_rate;
else
st_report("User options overriding rate read in .au header");
/* Read the number of channels */
st_readdw(ft, &channels);
- if (ft->info.channels == 0 || ft->info.channels == channels)
- ft->info.channels = channels;
+ if (ft->signal.channels == 0 || ft->signal.channels == channels)
+ ft->signal.channels = channels;
else
st_report("User options overriding channels read in .au header");
@@ -269,7 +269,7 @@
st_report("Input file %s: Sun header info: %s", ft->filename, buf);
}
/* Needed for seeking */
- ft->length = data_size/ft->info.size;
+ ft->length = data_size/ft->signal.size;
if(ft->seekable)
p->dataStart = st_tell(ft);
@@ -350,7 +350,7 @@
static st_size_t st_auwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
au_t p = (au_t ) ft->priv;
- p->data_size += samp * ft->info.size;
+ p->data_size += samp * ft->signal.size;
return(st_rawwrite(ft, buf, samp));
}
@@ -410,14 +410,14 @@
int x;
int comment_size;
- if ((encoding = st_ausunencoding(ft->info.size, ft->info.encoding)) == -1) {
+ if ((encoding = st_ausunencoding(ft->signal.size, ft->signal.encoding)) == -1) {
st_report("Unsupported output encoding/size for Sun/NeXT header or .AU format not specified.");
st_report("Only U-law, A-law, and signed bytes/words/tri-bytes are supported.");
st_report("Defaulting to 8khz u-law");
encoding = SUN_ULAW;
- ft->info.encoding = ST_ENCODING_ULAW;
- ft->info.size = ST_SIZE_BYTE;
- ft->info.rate = 8000; /* strange but true */
+ ft->signal.encoding = ST_ENCODING_ULAW;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.rate = 8000; /* strange but true */
}
magic = SUN_MAGIC;
@@ -443,10 +443,10 @@
st_writedw(ft, encoding);
- sample_rate = ft->info.rate;
+ sample_rate = ft->signal.rate;
st_writedw(ft, sample_rate);
- channels = ft->info.channels;
+ channels = ft->signal.channels;
st_writedw(ft, channels);
st_writes(ft, ft->comment);
--- a/src/avr.c
+++ b/src/avr.c
@@ -79,18 +79,18 @@
st_readw (ft, &(avr->mono));
if (avr->mono) {
- ft->info.channels = 2;
+ ft->signal.channels = 2;
}
else {
- ft->info.channels = 1;
+ ft->signal.channels = 1;
}
st_readw (ft, &(avr->rez));
if (avr->rez == 8) {
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.size = ST_SIZE_BYTE;
}
else if (avr->rez == 16) {
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.size = ST_SIZE_WORD;
}
else {
st_fail_errno(ft,ST_EFMT,"AVR: unsupported sample resolution");
@@ -99,10 +99,10 @@
st_readw (ft, &(avr->sign));
if (avr->sign) {
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
else {
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
st_readw (ft, &(avr->loop));
@@ -116,7 +116,7 @@
*
* Just masking the upper byte out.
*/
- ft->info.rate = (avr->rate & 0x00ffffff);
+ ft->signal.rate = (avr->rate & 0x00ffffff);
st_readdw (ft, &(avr->size));
@@ -169,10 +169,10 @@
st_writeb(ft, 0);
/* mono */
- if (ft->info.channels == 1) {
+ if (ft->signal.channels == 1) {
st_writew (ft, 0);
}
- else if (ft->info.channels == 2) {
+ else if (ft->signal.channels == 2) {
st_writew (ft, 0xffff);
}
else {
@@ -181,10 +181,10 @@
}
/* rez */
- if (ft->info.size == ST_SIZE_BYTE) {
+ if (ft->signal.size == ST_SIZE_BYTE) {
st_writew (ft, 8);
}
- else if (ft->info.size == ST_SIZE_WORD) {
+ else if (ft->signal.size == ST_SIZE_WORD) {
st_writew (ft, 16);
}
else {
@@ -193,10 +193,10 @@
}
/* sign */
- if (ft->info.encoding == ST_ENCODING_SIGN2) {
+ if (ft->signal.encoding == ST_ENCODING_SIGN2) {
st_writew (ft, 0xffff);
}
- else if (ft->info.encoding == ST_ENCODING_UNSIGNED) {
+ else if (ft->signal.encoding == ST_ENCODING_UNSIGNED) {
st_writew (ft, 0);
}
else {
@@ -211,7 +211,7 @@
st_writew (ft, 0xffff);
/* rate */
- st_writedw (ft, ft->info.rate);
+ st_writedw (ft, ft->signal.rate);
/* size */
/* Don't know the size yet. */
@@ -260,7 +260,7 @@
avr_t avr = (avr_t)ft->priv;
int rc;
- int size = avr->size / ft->info.channels;
+ int size = avr->size / ft->signal.channels;
rc = st_rawstopwrite(ft);
if (rc)
--- a/src/cdr.c
+++ b/src/cdr.c
@@ -48,10 +48,10 @@
if (rc)
return rc;
- ft->info.rate = 44100L;
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.channels = 2;
+ ft->signal.rate = 44100L;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.channels = 2;
ft->comment = NULL;
/* Need length for seeking */
@@ -99,10 +99,10 @@
cdr->samples = 0;
- ft->info.rate = 44100L;
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.channels = 2;
+ ft->signal.rate = 44100L;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.channels = 2;
return(ST_SUCCESS);
}
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -115,12 +115,12 @@
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
- p->cvsd_rate = (ft->info.rate <= 24000) ? 16000 : 32000;
- ft->info.rate = 8000;
- ft->info.channels = 1;
- ft->info.size = ST_SIZE_WORD; /* make output format default to words */
- ft->info.encoding = ST_ENCODING_SIGN2;
- p->swapbits = ft->info.reverse_bits;
+ p->cvsd_rate = (ft->signal.rate <= 24000) ? 16000 : 32000;
+ ft->signal.rate = 8000;
+ ft->signal.channels = 1;
+ ft->signal.size = ST_SIZE_WORD; /* make output format default to words */
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ p->swapbits = ft->signal.reverse_bits;
/*
* initialize the decoder
*/
@@ -512,10 +512,10 @@
st_debug(" custom1 %u", hdr.Custom1);
st_debug(" custom2 %u", hdr.Custom2);
st_debug(" info \"%.16s\"", hdr.Info);
- ft->info.rate = (hdr.Srate < 240) ? 16000 : 32000;
+ ft->signal.rate = (hdr.Srate < 240) ? 16000 : 32000;
st_debug("DVMS rate %dbit/s using %dbit/s deviation %d%%",
- hdr.Srate*100, ft->info.rate,
- ((ft->info.rate - hdr.Srate*100) * 100) / ft->info.rate);
+ hdr.Srate*100, ft->signal.rate,
+ ((ft->signal.rate - hdr.Srate*100) * 100) / ft->signal.rate);
rc = st_cvsdstartread(ft);
if (rc)
return rc;
--- a/src/dat.c
+++ b/src/dat.c
@@ -35,9 +35,9 @@
inpstr[LINEWIDTH-1] = 0;
if ((sscanf(inpstr," %c", &sc) != 0) && (sc != ';')) break;
if (sscanf(inpstr," ; Sample Rate %ld", &rate)) {
- ft->info.rate=rate;
+ ft->signal.rate=rate;
} else if (sscanf(inpstr," ; Channels %d", &chan)) {
- ft->info.channels=chan;
+ ft->signal.channels=chan;
}
}
/* Hold a copy of the last line we read (first non-comment) */
@@ -49,11 +49,11 @@
}
/* Default channels to 1 if not found */
- if (ft->info.channels == 0)
- ft->info.channels = 1;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = 1;
- ft->info.size = ST_SIZE_64BIT;
- ft->info.encoding = ST_ENCODING_FLOAT;
+ ft->signal.size = ST_SIZE_64BIT;
+ ft->signal.encoding = ST_ENCODING_FLOAT;
return (ST_SUCCESS);
}
@@ -63,14 +63,14 @@
dat_t dat = (dat_t) ft->priv;
char s[LINEWIDTH];
- ft->info.size = ST_SIZE_64BIT;
- ft->info.encoding = ST_ENCODING_FLOAT;
+ ft->signal.size = ST_SIZE_64BIT;
+ ft->signal.encoding = ST_ENCODING_FLOAT;
dat->timevalue = 0.0;
- dat->deltat = 1.0 / (double)ft->info.rate;
+ dat->deltat = 1.0 / (double)ft->signal.rate;
/* Write format comments to start of file */
- sprintf(s,"; Sample Rate %ld\015\n", (long)ft->info.rate);
+ sprintf(s,"; Sample Rate %ld\015\n", (long)ft->signal.rate);
st_writes(ft, s);
- sprintf(s,"; Channels %d\015\n", (int)ft->info.channels);
+ sprintf(s,"; Channels %d\015\n", (int)ft->signal.channels);
st_writes(ft, s);
return (ST_SUCCESS);
@@ -88,7 +88,7 @@
st_size_t i=0;
/* Always read a complete set of channels */
- nsamp -= (nsamp % ft->info.channels);
+ nsamp -= (nsamp % ft->signal.channels);
while (done < nsamp) {
@@ -107,7 +107,7 @@
/* Read a complete set of channels */
sscanf(inpstr," %*s%n", &inpPtr);
- for (i=0; i<ft->info.channels; i++) {
+ for (i=0; i<ft->signal.channels; i++) {
retc = sscanf(&inpstr[inpPtr]," %lg%n", &sampval, &inpPtrInc);
inpPtr += inpPtrInc;
if (retc != 1) {
@@ -132,13 +132,13 @@
st_size_t i=0;
/* Always write a complete set of channels */
- nsamp -= (nsamp % ft->info.channels);
+ nsamp -= (nsamp % ft->signal.channels);
/* Write time, then sample values, then CRLF newline */
while(done < nsamp) {
sprintf(s," %15.8g ",dat->timevalue);
st_writes(ft, s);
- for (i=0; i<ft->info.channels; i++) {
+ for (i=0; i<ft->signal.channels; i++) {
sampval = ST_SAMPLE_TO_FLOAT_DDWORD(*buf++, ft->clippedCount);
sprintf(s," %15.8g", sampval);
st_writes(ft, s);
--- a/src/flac.c
+++ b/src/flac.c
@@ -161,10 +161,10 @@
return ST_EOF;
}
- format->info.encoding = ST_ENCODING_FLAC;
- format->info.rate = decoder->sample_rate;
- format->info.size = decoder->bits_per_sample >> 3;
- format->info.channels = decoder->channels;
+ format->signal.encoding = ST_ENCODING_FLAC;
+ format->signal.rate = decoder->sample_rate;
+ format->signal.size = decoder->bits_per_sample >> 3;
+ format->signal.channels = decoder->channels;
format->length = decoder->total_samples * decoder->channels;
return ST_SUCCESS;
}
@@ -296,10 +296,10 @@
};
unsigned compression_level = array_length(options) - 1; /* Default to "best" */
- if (format->info.compression != HUGE_VAL)
+ if (format->signal.compression != HUGE_VAL)
{
- compression_level = format->info.compression;
- if (compression_level != format->info.compression ||
+ compression_level = format->signal.compression;
+ if (compression_level != format->signal.compression ||
compression_level >= array_length(options))
{
st_fail_errno(format, ST_EINVAL,
@@ -318,7 +318,7 @@
SET_OPTION(max_lpc_order);
SET_OPTION(max_residual_partition_order);
SET_OPTION(min_residual_partition_order);
- if (format->info.channels == 2)
+ if (format->signal.channels == 2)
{
SET_OPTION(do_mid_side_stereo);
SET_OPTION(loose_mid_side_stereo);
@@ -326,12 +326,12 @@
#undef SET_OPTION
}
- encoder->bits_per_sample = (format->info.size > 4 ? 4 : format->info.size) << 3;
+ encoder->bits_per_sample = (format->signal.size > 4 ? 4 : format->signal.size) << 3;
st_report("FLAC encoding at %i bits per sample", encoder->bits_per_sample);
- FLAC__stream_encoder_set_channels(encoder->flac, format->info.channels);
+ FLAC__stream_encoder_set_channels(encoder->flac, format->signal.channels);
FLAC__stream_encoder_set_bits_per_sample(encoder->flac, encoder->bits_per_sample);
- FLAC__stream_encoder_set_sample_rate(encoder->flac, format->info.rate);
+ FLAC__stream_encoder_set_sample_rate(encoder->flac, format->signal.rate);
{ /* Check if rate is streamable: */
static const unsigned streamable_rates[] =
@@ -340,7 +340,7 @@
bool streamable = false;
for (i = 0; !streamable && i < array_length(streamable_rates); ++i)
{
- streamable = (streamable_rates[i] == format->info.rate);
+ streamable = (streamable_rates[i] == format->signal.rate);
}
if (!streamable)
{
@@ -423,7 +423,7 @@
case 32: encoder->decoded_samples[i] = ST_SAMPLE_TO_SIGNED_DWORD(sampleBuffer[i],); break;
}
}
- FLAC__stream_encoder_process_interleaved(encoder->flac, encoder->decoded_samples, len / format->info.channels);
+ FLAC__stream_encoder_process_interleaved(encoder->flac, encoder->decoded_samples, len / format->signal.channels);
return FLAC__stream_encoder_get_state(encoder->flac) == FLAC__STREAM_ENCODER_OK ? len : 0;
}
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -58,18 +58,18 @@
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
int ch;
- ft->info.encoding = ST_ENCODING_GSM;
- ft->info.size = ST_SIZE_BYTE;
- if (!ft->info.rate)
- ft->info.rate = 8000;
+ ft->signal.encoding = ST_ENCODING_GSM;
+ ft->signal.size = ST_SIZE_BYTE;
+ if (!ft->signal.rate)
+ ft->signal.rate = 8000;
- if (ft->info.channels == 0)
- ft->info.channels = 1;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = 1;
- p->channels = ft->info.channels;
+ p->channels = ft->signal.channels;
if (p->channels > MAXCHANS || p->channels <= 0)
{
- st_fail_errno(ft,ST_EFMT,"gsm: channels(%d) must be in 1-16", ft->info.channels);
+ st_fail_errno(ft,ST_EFMT,"gsm: channels(%d) must be in 1-16", ft->signal.channels);
return(ST_EOF);
}
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -116,10 +116,10 @@
st_readw(ft, &dictsize);
/* Translate to sox parameters */
- ft->info.encoding = ST_ENCODING_UNSIGNED;
- ft->info.size = ST_SIZE_BYTE;
- ft->info.rate = 22050 / divisor;
- ft->info.channels = 1;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.rate = 22050 / divisor;
+ ft->signal.channels = 1;
/* Allocate memory for the dictionary */
p->dictionary = (dictent *)xmalloc(511 * sizeof(dictent));
@@ -244,7 +244,7 @@
{
register struct writepriv *p = (struct writepriv *) ft->priv;
- switch (ft->info.rate) {
+ switch (ft->signal.rate) {
case 22050:
case 22050/2:
case 22050/3:
@@ -254,9 +254,9 @@
st_fail_errno(ft,ST_EFMT,"unacceptable output rate for HCOM: try 5512, 7350, 11025 or 22050 hertz");
return (ST_EOF);
}
- ft->info.size = ST_SIZE_BYTE;
- ft->info.encoding = ST_ENCODING_UNSIGNED;
- ft->info.channels = 1;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.channels = 1;
p->size = BUFINCR;
p->pos = 0;
@@ -434,7 +434,7 @@
/* Compress it all at once */
if (compressed_len)
- compress(ft, &compressed_data, (int32_t *)&compressed_len, (double) ft->info.rate);
+ compress(ft, &compressed_data, (int32_t *)&compressed_len, (double) ft->signal.rate);
free((char *)p->data);
/* Write the header */
--- a/src/maud.c
+++ b/src/maud.c
@@ -107,15 +107,15 @@
return (ST_EOF);
}
- ft->info.rate = nom / denom;
+ ft->signal.rate = nom / denom;
st_readw(ft, &chaninf); /* channel information */
switch (chaninf) {
case 0:
- ft->info.channels = 1;
+ ft->signal.channels = 1;
break;
case 1:
- ft->info.channels = 2;
+ ft->signal.channels = 2;
break;
default:
st_fail_errno(ft,ST_EFMT,"MAUD: unsupported number of channels in file");
@@ -123,7 +123,7 @@
}
st_readw(ft, &chaninf); /* number of channels (mono: 1, stereo: 2, ...) */
- if (chaninf != ft->info.channels)
+ if (chaninf != ft->signal.channels)
{
st_fail_errno(ft,ST_EFMT,"MAUD: unsupported number of channels in file");
return(ST_EOF);
@@ -136,20 +136,20 @@
st_readdw(ft, &trash32);
if (bitpersam == 8 && chaninf == 0) {
- ft->info.size = ST_SIZE_BYTE;
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
else if (bitpersam == 8 && chaninf == 2) {
- ft->info.size = ST_SIZE_BYTE;
- ft->info.encoding = ST_ENCODING_ALAW;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_ALAW;
}
else if (bitpersam == 8 && chaninf == 3) {
- ft->info.size = ST_SIZE_BYTE;
- ft->info.encoding = ST_ENCODING_ULAW;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_ULAW;
}
else if (bitpersam == 16 && chaninf == 0) {
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
else
{
@@ -215,16 +215,16 @@
return (ST_EOF);
}
- if (ft->info.channels != 1 && ft->info.channels != 2) {
+ if (ft->signal.channels != 1 && ft->signal.channels != 2) {
st_fail_errno(ft,ST_EFMT,"MAUD: unsupported number of channels, unable to store");
return(ST_EOF);
}
- if (ft->info.size == ST_SIZE_WORD) ft->info.encoding = ST_ENCODING_SIGN2;
- if (ft->info.encoding == ST_ENCODING_ULAW ||
- ft->info.encoding == ST_ENCODING_ALAW) ft->info.size = ST_SIZE_BYTE;
- if (ft->info.size == ST_SIZE_BYTE &&
- ft->info.encoding == ST_ENCODING_SIGN2)
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ if (ft->signal.size == ST_SIZE_WORD) ft->signal.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.encoding == ST_ENCODING_ULAW ||
+ ft->signal.encoding == ST_ENCODING_ALAW) ft->signal.size = ST_SIZE_BYTE;
+ if (ft->signal.size == ST_SIZE_BYTE &&
+ ft->signal.encoding == ST_ENCODING_SIGN2)
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
p->nsamples = 0x7f000000L;
maudwriteheader(ft);
@@ -268,7 +268,7 @@
struct maudstuff * p = (struct maudstuff *) ft->priv;
st_writes(ft, "FORM");
- st_writedw(ft, (p->nsamples*ft->info.size) + MAUDHEADERSIZE); /* size of file */
+ st_writedw(ft, (p->nsamples*ft->signal.size) + MAUDHEADERSIZE); /* size of file */
st_writes(ft, "MAUD"); /* File type */
st_writes(ft, "MHDR");
@@ -275,7 +275,7 @@
st_writedw(ft, 8*4); /* number of bytes to follow */
st_writedw(ft, p->nsamples); /* number of samples stored in MDAT */
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_UNSIGNED:
st_writew(ft, (int) 8); /* number of bits per sample as stored in MDAT */
@@ -297,10 +297,10 @@
break;
}
- st_writedw(ft, ft->info.rate); /* clock source frequency */
+ st_writedw(ft, ft->signal.rate); /* clock source frequency */
st_writew(ft, (int) 1); /* clock devide */
- if (ft->info.channels == 1) {
+ if (ft->signal.channels == 1) {
st_writew(ft, (int) 0); /* channel information */
st_writew(ft, (int) 1); /* number of channels (mono: 1, stereo: 2, ...) */
}
@@ -309,7 +309,7 @@
st_writew(ft, (int) 2);
}
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_UNSIGNED:
case ST_ENCODING_SIGN2:
@@ -337,7 +337,7 @@
st_writes(ft, "file create by Sound eXchange ");
st_writes(ft, "MDAT");
- st_writedw(ft, p->nsamples * ft->info.size ); /* samples in file */
+ st_writedw(ft, p->nsamples * ft->signal.size ); /* samples in file */
}
/* Amiga MAUD */
--- a/src/misc.c
+++ b/src/misc.c
@@ -228,7 +228,7 @@
st_fail_errno(ft,errno,readerr);
return (ST_EOF);
}
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
*uw = st_swapw(*uw);
return ST_SUCCESS;
}
@@ -236,7 +236,7 @@
/* Write word. */
int st_writew(ft_t ft, uint16_t uw)
{
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
uw = st_swapw(uw);
if (st_writebuf(ft, &uw, 2, 1) != 1)
{
@@ -254,7 +254,7 @@
st_fail_errno(ft,errno,readerr);
return (ST_EOF);
}
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
*u3 = st_swap24(*u3);
return ST_SUCCESS;
}
@@ -262,7 +262,7 @@
/* Write three bytes. */
int st_write3(ft_t ft, uint24_t u3)
{
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
u3 = st_swap24(u3);
if (st_writebuf(ft, &u3, 3, 1) != 1)
{
@@ -280,7 +280,7 @@
st_fail_errno(ft,errno,readerr);
return (ST_EOF);
}
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
*udw = st_swapdw(*udw);
return ST_SUCCESS;
}
@@ -288,7 +288,7 @@
/* Write double word. */
int st_writedw(ft_t ft, uint32_t udw)
{
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
udw = st_swapdw(udw);
if (st_writebuf(ft, &udw, 4, 1) != 1)
{
@@ -306,7 +306,7 @@
st_fail_errno(ft,errno,readerr);
return(ST_EOF);
}
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
*f = st_swapf(*f);
return ST_SUCCESS;
}
@@ -316,7 +316,7 @@
{
float t = f;
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
t = st_swapf(t);
if (st_writebuf(ft, &t, sizeof(float), 1) != 1)
{
@@ -334,7 +334,7 @@
st_fail_errno(ft,errno,readerr);
return(ST_EOF);
}
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
*d = st_swapd(*d);
return ST_SUCCESS;
}
@@ -342,7 +342,7 @@
/* Write double. */
int st_writedf(ft_t ft, double d)
{
- if (ft->info.swap_bytes)
+ if (ft->signal.swap_bytes)
d = st_swapd(d);
if (st_writebuf(ft, &d, sizeof(double), 1) != 1)
{
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -181,8 +181,8 @@
mad_synth_init(p->Synth);
mad_timer_reset(p->Timer);
- ft->info.encoding = ST_ENCODING_MP3;
- ft->info.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_MP3;
+ ft->signal.size = ST_SIZE_WORD;
/* Decode at least one valid frame to find out the input
* format. The decoded frame will be saved off so that it
@@ -239,7 +239,7 @@
case MAD_MODE_DUAL_CHANNEL:
case MAD_MODE_JOINT_STEREO:
case MAD_MODE_STEREO:
- ft->info.channels = MAD_NCHANNELS(&p->Frame->header);
+ ft->signal.channels = MAD_NCHANNELS(&p->Frame->header);
break;
default:
st_fail_errno(ft, ST_EFMT, "Cannot determine number of channels");
@@ -250,7 +250,7 @@
mad_timer_add(p->Timer,p->Frame->header.duration);
mad_synth_frame(p->Synth,p->Frame);
- ft->info.rate=p->Synth->pcm.samplerate;
+ ft->signal.rate=p->Synth->pcm.samplerate;
p->cursamp = 0;
@@ -271,10 +271,10 @@
size_t chan;
do {
- donow=min(len,(p->Synth->pcm.length - p->cursamp)*ft->info.channels);
+ donow=min(len,(p->Synth->pcm.length - p->cursamp)*ft->signal.channels);
i=0;
while(i<donow){
- for(chan=0;chan<ft->info.channels;chan++){
+ for(chan=0;chan<ft->signal.channels;chan++){
sample=p->Synth->pcm.samples[chan][p->cursamp];
if (sample < -MAD_F_ONE)
sample=-MAD_F_ONE;
@@ -372,10 +372,10 @@
{
struct mp3priv *p = (struct mp3priv *) ft->priv;
- if (ft->info.encoding != ST_ENCODING_MP3) {
- if(ft->info.encoding != ST_ENCODING_UNKNOWN)
+ if (ft->signal.encoding != ST_ENCODING_MP3) {
+ if(ft->signal.encoding != ST_ENCODING_UNKNOWN)
st_report("Encoding forced to MP3");
- ft->info.encoding = ST_ENCODING_MP3;
+ ft->signal.encoding = ST_ENCODING_MP3;
}
p->gfp = lame_init();
@@ -384,16 +384,16 @@
return(ST_EOF);
}
- if (ft->info.channels != ST_ENCODING_UNKNOWN) {
- if ( (lame_set_num_channels(p->gfp,ft->info.channels)) < 0) {
+ if (ft->signal.channels != ST_ENCODING_UNKNOWN) {
+ if ( (lame_set_num_channels(p->gfp,ft->signal.channels)) < 0) {
st_fail_errno(ft,ST_EOF,"Unsupported number of channels");
return(ST_EOF);
}
}
else
- ft->info.channels = lame_get_num_channels(p->gfp); /* LAME default */
+ ft->signal.channels = lame_get_num_channels(p->gfp); /* LAME default */
- lame_set_in_samplerate(p->gfp,ft->info.rate);
+ lame_set_in_samplerate(p->gfp,ft->signal.rate);
lame_set_bWriteVbrTag(p->gfp, 0); /* disable writing VBR tag */
@@ -403,7 +403,7 @@
/* FIXME: Someone who knows about lame could implement adjustable compression
here. E.g. by using the -C value as an index into a table of params or
as a compressed bit-rate. */
- if (ft->info.compression != HUGE_VAL)
+ if (ft->signal.compression != HUGE_VAL)
st_warn("-C option not supported for mp3; using default compression rate");
if (lame_init_params(p->gfp) < 0){
st_fail_errno(ft,ST_EOF,"LAME initialization failed");
@@ -422,7 +422,7 @@
char *mp3buffer;
st_size_t mp3buffer_size;
short signed int *buffer_l, *buffer_r = NULL;
- int nsamples = samp/ft->info.channels;
+ int nsamples = samp/ft->signal.channels;
int i,j;
st_ssize_t done = 0;
st_size_t written;
@@ -445,7 +445,7 @@
*/
buffer_l = (short signed int *)xmalloc(nsamples * sizeof(short signed int));
- if (ft->info.channels == 2)
+ if (ft->signal.channels == 2)
{
/* lame doesn't support iterleaved samples so we must break
* them out into seperate buffers.
@@ -494,12 +494,12 @@
goto end;
}
- done = nsamples*ft->info.channels;
+ done = nsamples*ft->signal.channels;
end:
free(mp3buffer);
end2:
- if (ft->info.channels == 2)
+ if (ft->signal.channels == 2)
free(buffer_r);
end3:
free(buffer_l);
--- a/src/nulfile.c
+++ b/src/nulfile.c
@@ -21,10 +21,10 @@
{
/* If format parameters are not given, set somewhat arbitrary
* (but commonly used) defaults: */
- if (ft->info.rate == 0) ft->info.rate = 44100;
- if (ft->info.channels == 0) ft->info.channels = 2;
- if (ft->info.size ==-1) ft->info.size = ST_SIZE_WORD;
- if (ft->info.encoding == ST_ENCODING_UNKNOWN) ft->info.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.rate == 0) ft->signal.rate = 44100;
+ if (ft->signal.channels == 0) ft->signal.channels = 2;
+ if (ft->signal.size ==-1) ft->signal.size = ST_SIZE_WORD;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN) ft->signal.encoding = ST_ENCODING_SIGN2;
return ST_SUCCESS;
}
--- a/src/oss.c
+++ b/src/oss.c
@@ -48,41 +48,41 @@
int tmp, rc;
st_fileinfo_t *file = (st_fileinfo_t *)ft->priv;
- if (ft->info.rate == 0.0) ft->info.rate = 8000;
- if (ft->info.size == -1) ft->info.size = ST_SIZE_BYTE;
- if (ft->info.size == ST_SIZE_BYTE) {
+ if (ft->signal.rate == 0.0) ft->signal.rate = 8000;
+ if (ft->signal.size == -1) ft->signal.size = ST_SIZE_BYTE;
+ if (ft->signal.size == ST_SIZE_BYTE) {
sampletype = AFMT_U8;
samplesize = 8;
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
- ft->info.encoding = ST_ENCODING_UNSIGNED;
- if (ft->info.encoding != ST_ENCODING_UNSIGNED) {
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
+ if (ft->signal.encoding != ST_ENCODING_UNSIGNED) {
st_report("OSS driver only supports unsigned with bytes");
st_report("Forcing to unsigned");
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
}
- else if (ft->info.size == ST_SIZE_WORD) {
+ else if (ft->signal.size == ST_SIZE_WORD) {
sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
samplesize = 16;
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
- ft->info.encoding = ST_ENCODING_SIGN2;
- if (ft->info.encoding != ST_ENCODING_SIGN2) {
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.encoding != ST_ENCODING_SIGN2) {
st_report("OSS driver only supports signed with words");
st_report("Forcing to signed linear");
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
}
else {
sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
samplesize = 16;
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
st_report("OSS driver only supports bytes and words");
st_report("Forcing to signed linear word");
}
- if (ft->info.channels == 0) ft->info.channels = 1;
- else if (ft->info.channels > 2) ft->info.channels = 2;
+ if (ft->signal.channels == 0) ft->signal.channels = 1;
+ else if (ft->signal.channels > 2) ft->signal.channels = 2;
if (ioctl(fileno(ft->fp), SNDCTL_DSP_RESET, 0) < 0)
{
@@ -100,8 +100,8 @@
if (samplesize == 16 && (tmp & (AFMT_S16_LE|AFMT_S16_BE)) == 0)
{
/* Must not like 16-bits, try 8-bits */
- ft->info.size = ST_SIZE_BYTE;
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
st_report("OSS driver doesn't like signed words");
st_report("Forcing to unsigned bytes");
tmp = sampletype = AFMT_U8;
@@ -110,8 +110,8 @@
/* is 8-bit supported */
else if (samplesize == 8 && (tmp & AFMT_U8) == 0)
{
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
st_report("OSS driver doesn't like unsigned bytes");
st_report("Forcing to signed words");
sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
@@ -132,9 +132,9 @@
}
if (samplesize == 16)
- ft->info.swap_bytes = ST_IS_BIGENDIAN != (sampletype == AFMT_S16_BE);
+ ft->signal.swap_bytes = ST_IS_BIGENDIAN != (sampletype == AFMT_S16_BE);
- if (ft->info.channels == 2) dsp_stereo = 1;
+ if (ft->signal.channels == 2) dsp_stereo = 1;
else dsp_stereo = 0;
tmp = dsp_stereo;
@@ -147,12 +147,12 @@
if (tmp != dsp_stereo)
{
st_warn("Sound card appears to only support %d channels. Overriding format", tmp+1);
- ft->info.channels = tmp + 1;
+ ft->signal.channels = tmp + 1;
}
- tmp = ft->info.rate;
+ tmp = ft->signal.rate;
if (ioctl (fileno(ft->fp), SNDCTL_DSP_SPEED, &tmp) < 0 ||
- (int)ft->info.rate != tmp) {
+ (int)ft->signal.rate != tmp) {
/* If the rate the sound card is using is not within 1% of what
* the user specified then override the user setting.
* The only reason not to always override this is because of
@@ -161,11 +161,11 @@
* this and having strange output file rates for something that
* we can't hear anyways.
*/
- if ((int)ft->info.rate - tmp > (tmp * .01) ||
- tmp - (int)ft->info.rate > (tmp * .01)) {
+ if ((int)ft->signal.rate - tmp > (tmp * .01) ||
+ tmp - (int)ft->signal.rate > (tmp * .01)) {
st_warn("Unable to set audio speed to %d (set to %d)",
- ft->info.rate, tmp);
- ft->info.rate = tmp;
+ ft->signal.rate, tmp);
+ ft->signal.rate = tmp;
}
}
--- a/src/prc.c
+++ b/src/prc.c
@@ -57,9 +57,9 @@
prc_t prc = (prc_t ) ft->priv;
st_size_t new_offset, channel_block, alignment;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (i.e. left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -101,19 +101,19 @@
/* dummy read rest */
st_readbuf(ft, head,1,14+2+2);
- ft->info.encoding = ST_ENCODING_ALAW;
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_ALAW;
+ ft->signal.size = ST_SIZE_BYTE;
- if (ft->info.rate != 0)
+ if (ft->signal.rate != 0)
st_report("PRC must use 8000 sample rate. Overriding");
- ft->info.rate = 8000;
+ ft->signal.rate = 8000;
- if (ft->info.channels != ST_ENCODING_UNKNOWN && ft->info.channels != 0)
+ if (ft->signal.channels != ST_ENCODING_UNKNOWN && ft->signal.channels != 0)
st_report("PRC must only supports 1 channel. Overriding");
- ft->info.channels = 1;
+ ft->signal.channels = 1;
p->dataStart = st_tell(ft);
- ft->length = p->length/ft->info.size;
+ ft->length = p->length/ft->signal.size;
return (ST_SUCCESS);
}
@@ -141,15 +141,15 @@
if (p->repeats == 0)
p->repeats = 1;
- if (ft->info.rate != 0)
+ if (ft->signal.rate != 0)
st_report("PRC must use 8000 sample rate. Overriding");
- if (ft->info.channels != ST_ENCODING_UNKNOWN && ft->info.channels != 0)
+ if (ft->signal.channels != ST_ENCODING_UNKNOWN && ft->signal.channels != 0)
st_report("PRC must only supports 1 channel. Overriding");
- ft->info.encoding = ST_ENCODING_ALAW;
- ft->info.size = ST_SIZE_BYTE;
- ft->info.rate = 8000;
+ ft->signal.encoding = ST_ENCODING_ALAW;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.rate = 8000;
prcwriteheader(ft);
return ST_SUCCESS;
@@ -158,7 +158,7 @@
static st_size_t st_prcwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
prc_t p = (prc_t ) ft->priv;
- p->length += samp * ft->info.size;
+ p->length += samp * ft->signal.size;
st_debug("length now = %d", p->length);
return st_rawwrite(ft, buf, samp);
}
--- a/src/raw.c
+++ b/src/raw.c
@@ -71,7 +71,7 @@
{
st_size_t new_offset, channel_block, alignment;
- switch(ft->info.size) {
+ switch(ft->signal.size) {
case ST_SIZE_BYTE:
case ST_SIZE_WORD:
case ST_SIZE_24BIT:
@@ -83,9 +83,9 @@
return ft->st_errno;
}
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -168,9 +168,9 @@
static ft_io_fun *check_format(ft_t ft, bool write)
{
- switch (ft->info.size) {
+ switch (ft->signal.size) {
case ST_SIZE_BYTE:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_SIGN2:
return write ? st_sb_write_buf : st_sb_read_buf;
case ST_ENCODING_UNSIGNED:
@@ -189,7 +189,7 @@
break;
case ST_SIZE_WORD:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_SIGN2:
return write ? st_sw_write_buf : st_sw_read_buf;
case ST_ENCODING_UNSIGNED:
@@ -200,7 +200,7 @@
break;
case ST_SIZE_24BIT:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_SIGN2:
return write ? st_s3_write_buf : st_s3_read_buf;
case ST_ENCODING_UNSIGNED:
@@ -211,7 +211,7 @@
break;
case ST_SIZE_DWORD:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_SIGN2:
return write ? st_dw_write_buf : st_dw_read_buf;
case ST_ENCODING_UNSIGNED:
@@ -224,7 +224,7 @@
break;
case ST_SIZE_DDWORD:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_FLOAT:
return write ? st_df_write_buf : st_df_read_buf;
default:
@@ -283,8 +283,8 @@
#define STARTREAD(NAME,SIZE,STYLE) \
static int NAME(ft_t ft) \
{ \
- ft->info.size = SIZE; \
- ft->info.encoding = STYLE; \
+ ft->signal.size = SIZE; \
+ ft->signal.encoding = STYLE; \
rawdefaults(ft); \
return st_rawstartread(ft); \
}
@@ -292,8 +292,8 @@
#define STARTWRITE(NAME,SIZE,STYLE)\
static int NAME(ft_t ft) \
{ \
- ft->info.size = SIZE; \
- ft->info.encoding = STYLE; \
+ ft->signal.size = SIZE; \
+ ft->signal.encoding = STYLE; \
rawdefaults(ft); \
return st_rawstartwrite(ft); \
}
@@ -336,10 +336,10 @@
void rawdefaults(ft_t ft)
{
- if (ft->info.rate == 0)
- ft->info.rate = 8000;
- if (ft->info.channels == 0)
- ft->info.channels = 1;
+ if (ft->signal.rate == 0)
+ ft->signal.rate = 8000;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = 1;
}
static const char *rawnames[] = {
--- a/src/sf.c
+++ b/src/sf.c
@@ -39,7 +39,7 @@
sfcodep = (SFCODE *) &sfcodes(sfhead);
do {
sfcharp = (char *) sfcodep + sizeof(SFCODE);
- if (ft->info.swap_bytes) {
+ if (ft->signal.swap_bytes) {
sfcodep->bsize = st_swapdw(sfcodep->bsize);
sfcodep->code = st_swapdw(sfcodep->code);
}
@@ -68,9 +68,9 @@
st_size_t new_offset, channel_block, alignment;
sf_t sf = (sf_t ) ft->priv;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -103,7 +103,7 @@
return(ST_EOF);
}
memcpy(&sf->info, &sfhead.sfinfo, sizeof(struct sfinfo));
- if (ft->info.swap_bytes) {
+ if (ft->signal.swap_bytes) {
sf->info.sf_srate = st_swapf(sf->info.sf_srate);
sf->info.sf_packmode = st_swapdw(sf->info.sf_packmode);
sf->info.sf_chans = st_swapdw(sf->info.sf_chans);
@@ -119,16 +119,16 @@
* If your format specifies or your file header contains
* any of the following information.
*/
- ft->info.rate = sf->info.sf_srate;
+ ft->signal.rate = sf->info.sf_srate;
switch(sf->info.sf_packmode) {
case SF_SHORT:
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
- samplesize = ft->info.size;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ samplesize = ft->signal.size;
break;
case SF_FLOAT:
- ft->info.size = ST_SIZE_DWORD;
- ft->info.encoding = ST_ENCODING_FLOAT;
+ ft->signal.size = ST_SIZE_DWORD;
+ ft->signal.encoding = ST_ENCODING_FLOAT;
samplesize = sizeof(float);
break;
default:
@@ -136,10 +136,10 @@
sf->info.sf_packmode);
return(ST_EOF);
}
- ft->info.channels = (int) sf->info.sf_chans;
+ ft->signal.channels = (int) sf->info.sf_chans;
- if (ft->info.channels == 0)
- ft->info.channels = 1;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = 1;
/* Read codes and print as comments. */
readcodes(ft, &sfhead);
@@ -181,18 +181,18 @@
else
sf->info.magic_union._magic_bytes.sf_machine = SF_SUN;
- sf->info.sf_srate = ft->info.rate;
- if (ft->info.size == ST_SIZE_DWORD &&
- ft->info.encoding == ST_ENCODING_FLOAT) {
+ sf->info.sf_srate = ft->signal.rate;
+ if (ft->signal.size == ST_SIZE_DWORD &&
+ ft->signal.encoding == ST_ENCODING_FLOAT) {
sf->info.sf_packmode = SF_FLOAT;
} else {
sf->info.sf_packmode = SF_SHORT;
/* Default to signed words */
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
- sf->info.sf_chans = ft->info.channels;
+ sf->info.sf_chans = ft->signal.channels;
/* Clean out structure so unused areas will remain constain */
/* between different coverts and not rely on memory contents */
--- a/src/skel.c
+++ b/src/skel.c
@@ -52,10 +52,10 @@
* If your format contains a header with format information
* then you should set it here.
*/
- ft->info.rate = 44100L;
- ft->info.size = ST_SIZE_BYTE or WORD ...;
- ft->info.encoding = ST_ENCODING_UNSIGNED or SIGN2 ...;
- ft->info.channels = 1 or 2 or 4;
+ ft->signal.rate = 44100L;
+ ft->signal.size = ST_SIZE_BYTE or WORD ...;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED or SIGN2 ...;
+ ft->signal.channels = 1 or 2 or 4;
ft->comment = xmalloc(size_of_comment);
strcpy(ft->comment, "any comment in file header.");
@@ -62,7 +62,7 @@
/* If your format doesn't have a header then samples_in_file
* can be determined by the file size.
*/
- samples_in_file = st_filelength(ft)/ft->info.size;
+ samples_in_file = st_filelength(ft)/ft->signal.size;
/* If you can detect the length of your file, record it here. */
ft->length = samples_in_file;
@@ -84,16 +84,16 @@
st_sample_t l;
/* Always return a full frame of audio data */
- if (len % ft->info.size)
- len -= (len % ft->info.size);
+ if (len % ft->signal.size)
+ len -= (len % ft->signal.size);
for (done = 0; done < len; done++) {
if no more samples
break
get a sample
- switch (ft->info.size) {
+ switch (ft->signal.size) {
case ST_SIZE_BYTE:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_UNSIGNED;
*buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(sample);
break;
@@ -128,16 +128,16 @@
return ST_EOF;
}
- if (ft->info.rate != 44100L)
+ if (ft->signal.rate != 44100L)
st_fail_errno(ft, ST_EVALUE, "Output .skel file must have a sample rate of 44100");
- if (ft->info.size == -1) {
+ if (ft->signal.size == -1) {
st_fail_errno(ft, ST_EVALUE, "Did not specify a size for .skel output file");
return ST_EOF;
}
- error check ft->info.encoding;
- error check ft->info.channels;
+ error check ft->signal.encoding;
+ error check ft->signal.channels;
/* Write file header, if any */
/* Write comment field, if any */
@@ -151,9 +151,9 @@
skel_t sk = (skel_t)ft->priv;
st_size_t len = 0;
- switch (ft->info.size) {
+ switch (ft->signal.size) {
case ST_SIZE_BYTE:
- switch (ft->info.encoding) {
+ switch (ft->signal.encoding) {
case ST_ENCODING_UNSIGNED:
while (len--) {
len = st_writeb(ft, ST_SAMPLE_TO_UNSIGNED_BYTE(*buff++, ft->clippedCount));
--- a/src/smp.c
+++ b/src/smp.c
@@ -174,9 +174,9 @@
int new_offset, channel_block, alignment;
smp_t smp = (smp_t) ft->priv;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -189,7 +189,7 @@
ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
if( ft->st_errno == ST_SUCCESS )
- smp->NoOfSamps = ft->length - (new_offset / ft->info.size);
+ smp->NoOfSamps = ft->length - (new_offset / ft->signal.size);
return(ft->st_errno);
}
@@ -272,10 +272,10 @@
return(ST_EOF);
}
- ft->info.rate = (int) trailer.rate;
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.channels = 1;
+ ft->signal.rate = (int) trailer.rate;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.channels = 1;
smp->dataStart = samplestart;
ft->length = smp->NoOfSamps;
@@ -346,9 +346,9 @@
}
/* If your format specifies any of the following info. */
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.channels = 1;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.channels = 1;
strcpy(header.Id, SVmagic);
strcpy(header.version, SVvers);
@@ -389,7 +389,7 @@
struct smptrailer trailer;
/* Assign the trailer data */
- settrailer(ft, &trailer, ft->info.rate);
+ settrailer(ft, &trailer, ft->signal.rate);
writetrailer(ft, &trailer);
if (st_seeki(ft, 112, 0) == -1)
{
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -31,7 +31,7 @@
st_writedw (ft,nsamples);
st_writedw (ft,0);
st_writedw (ft,nsamples);
- st_writew (ft,(int) ft->info.rate);
+ st_writew (ft,(int) ft->signal.rate);
st_writew (ft,0);
st_writew (ft,10);
st_writew (ft,4);
@@ -45,9 +45,9 @@
st_size_t new_offset, channel_block, alignment;
snd_t snd = (snd_t ) ft->priv;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -118,10 +118,10 @@
st_debug("%s",buf);
}
- ft->info.channels = 1;
- ft->info.rate = rate;
- ft->info.encoding = ST_ENCODING_UNSIGNED;
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.channels = 1;
+ ft->signal.rate = rate;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.size = ST_SIZE_BYTE;
snd->dataStart = st_tell(ft);
ft->length = st_filelength(ft) - snd->dataStart;
@@ -140,9 +140,9 @@
return rc;
/* write header */
- ft->info.channels = 1;
- ft->info.encoding = ST_ENCODING_UNSIGNED;
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.channels = 1;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.size = ST_SIZE_BYTE;
p->nsamples = 0;
sndtwriteheader(ft, 0);
--- a/src/sox.c
+++ b/src/sox.c
@@ -75,24 +75,24 @@
static st_sample_t obufl[ST_BUFSIZ / 2];
static st_sample_t obufr[ST_BUFSIZ / 2];
-typedef struct file_options
+typedef struct file_info
{
char *filename;
char *filetype;
- st_signalinfo_t info;
+ st_signalinfo_t signal;
double volume;
char *comment;
st_size_t volume_clips;
-} * file_options_t;
+} *file_info_t;
/* local forward declarations */
-static bool doopts(file_options_t fo, int, char **);
+static bool doopts(file_info_t fo, int, char **);
static void usage(char const *) NORET;
static void usage_effect(char *) NORET;
static void process(void);
static void print_input_status(int input);
static void update_status(void);
-static void volumechange(st_sample_t * buf, st_ssize_t len, file_options_t fo);
+static void volumechange(st_sample_t * buf, st_ssize_t len, file_info_t fo);
static void parse_effects(int argc, char **argv);
static void check_effects(void);
static int start_effects(void);
@@ -106,7 +106,7 @@
#define MAX_FILES MAX_INPUT_FILES + 1
/* Arrays tracking input and output files */
-static file_options_t file_opts[MAX_FILES];
+static file_info_t file_opts[MAX_FILES];
static ft_t file_desc[MAX_FILES];
static size_t file_count = 0;
static size_t input_count = 0;
@@ -217,8 +217,8 @@
/* Loop over arguments and filenames, stop when an effect name is
* found. */
while (optind < argc && !is_effect_name(argv[optind])) {
- file_options_t fo;
- struct file_options fo_none;
+ file_info_t fo;
+ struct file_info fo_none;
if (file_count >= MAX_FILES) {
st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
@@ -226,11 +226,11 @@
}
fo = xcalloc(sizeof(*fo), 1);
- fo->info.size = -1;
- fo->info.encoding = ST_ENCODING_UNKNOWN;
- fo->info.channels = 0;
- fo->info.swap_bytes = ST_SWAP_DEFAULT;
- fo->info.compression = HUGE_VAL;
+ fo->signal.size = -1;
+ fo->signal.encoding = ST_ENCODING_UNKNOWN;
+ fo->signal.channels = 0;
+ fo->signal.swap_bytes = ST_SWAP_DEFAULT;
+ fo->signal.compression = HUGE_VAL;
fo->volume = HUGE_VAL;
fo->volume_clips = 0;
fo_none = *fo;
@@ -259,7 +259,7 @@
/* Check for misplaced input/output-specific options */
for (i = 0; i < input_count; ++i) {
- if (file_opts[i]->info.compression != HUGE_VAL)
+ if (file_opts[i]->signal.compression != HUGE_VAL)
usage("A compression factor can only be given for an output file");
if (file_opts[i]->comment != NULL)
usage("A comment can only be given for an output file");
@@ -277,7 +277,7 @@
file_opts[i]->volume = 1.0 / input_count;
file_desc[i] = st_open_read(file_opts[i]->filename,
- &file_opts[i]->info,
+ &file_opts[i]->signal,
file_opts[i]->filetype);
if (!file_desc[i])
/* st_open_read() will call st_warn for most errors.
@@ -380,7 +380,7 @@
{NULL, 0, NULL, 0}
};
-static bool doopts(file_options_t fo, int argc, char **argv)
+static bool doopts(file_info_t fo, int argc, char **argv)
{
while (true) {
int i; /* Needed since scanf %u allows negative numbers :( */
@@ -404,11 +404,11 @@
case 2:
if (!strcmp(optarg, "little"))
- fo->info.swap_bytes = ST_IS_BIGENDIAN;
+ fo->signal.swap_bytes = ST_IS_BIGENDIAN;
else if (!strcmp(optarg, "big"))
- fo->info.swap_bytes = ST_IS_LITTLEENDIAN;
+ fo->signal.swap_bytes = ST_IS_LITTLEENDIAN;
else if (!strcmp(optarg, "swap"))
- fo->info.swap_bytes = true;
+ fo->signal.swap_bytes = true;
break;
case 3:
@@ -460,7 +460,7 @@
st_fail("Rate value '%s' is not a positive integer", optarg);
exit(1);
}
- fo->info.rate = i;
+ fo->signal.rate = i;
break;
case 'v':
@@ -479,53 +479,53 @@
st_fail("Channels value '%s' is not a positive integer", optarg);
exit(1);
}
- fo->info.channels = i;
+ fo->signal.channels = i;
break;
case 'C':
- if (sscanf(optarg, "%lf %c", &fo->info.compression, &dummy) != 1) {
+ if (sscanf(optarg, "%lf %c", &fo->signal.compression, &dummy) != 1) {
st_fail("Compression value '%s' is not a number", optarg);
exit(1);
}
break;
- case '1': case 'b': fo->info.size = ST_SIZE_BYTE; break;
- case '2': case 'w': fo->info.size = ST_SIZE_WORD; break;
- case '3': fo->info.size = ST_SIZE_24BIT; break;
- case '4': case 'l': fo->info.size = ST_SIZE_DWORD; break;
- case '8': case 'd': fo->info.size = ST_SIZE_DDWORD; break;
+ case '1': case 'b': fo->signal.size = ST_SIZE_BYTE; break;
+ case '2': case 'w': fo->signal.size = ST_SIZE_WORD; break;
+ case '3': fo->signal.size = ST_SIZE_24BIT; break;
+ case '4': case 'l': fo->signal.size = ST_SIZE_DWORD; break;
+ case '8': case 'd': fo->signal.size = ST_SIZE_DDWORD; break;
- case 's': fo->info.encoding = ST_ENCODING_SIGN2; break;
- case 'u': fo->info.encoding = ST_ENCODING_UNSIGNED; break;
- case 'f': fo->info.encoding = ST_ENCODING_FLOAT; break;
- case 'a': fo->info.encoding = ST_ENCODING_ADPCM; break;
- case 'i': fo->info.encoding = ST_ENCODING_IMA_ADPCM; break;
- case 'g': fo->info.encoding = ST_ENCODING_GSM; break;
+ case 's': fo->signal.encoding = ST_ENCODING_SIGN2; break;
+ case 'u': fo->signal.encoding = ST_ENCODING_UNSIGNED; break;
+ case 'f': fo->signal.encoding = ST_ENCODING_FLOAT; break;
+ case 'a': fo->signal.encoding = ST_ENCODING_ADPCM; break;
+ case 'i': fo->signal.encoding = ST_ENCODING_IMA_ADPCM; break;
+ case 'g': fo->signal.encoding = ST_ENCODING_GSM; break;
- case 'U': fo->info.encoding = ST_ENCODING_ULAW;
- if (fo->info.size == -1)
- fo->info.size = ST_SIZE_BYTE;
+ case 'U': fo->signal.encoding = ST_ENCODING_ULAW;
+ if (fo->signal.size == -1)
+ fo->signal.size = ST_SIZE_BYTE;
break;
- case 'A': fo->info.encoding = ST_ENCODING_ALAW;
- if (fo->info.size == -1)
- fo->info.size = ST_SIZE_BYTE;
+ case 'A': fo->signal.encoding = ST_ENCODING_ALAW;
+ if (fo->signal.size == -1)
+ fo->signal.size = ST_SIZE_BYTE;
break;
case 'L':
- fo->info.swap_bytes = ST_IS_BIGENDIAN;
+ fo->signal.swap_bytes = ST_IS_BIGENDIAN;
break;
case 'B':
- fo->info.swap_bytes = ST_IS_LITTLEENDIAN;
+ fo->signal.swap_bytes = ST_IS_LITTLEENDIAN;
break;
case 'x':
- fo->info.swap_bytes = ST_SWAP_YES;
+ fo->signal.swap_bytes = ST_SWAP_YES;
break;
case 'X':
- fo->info.reverse_bits = true;
+ fo->signal.reverse_bits = true;
break;
case 'V':
@@ -554,9 +554,9 @@
static int compare_input(ft_t ft1, ft_t ft2)
{
- if (ft1->info.rate != ft2->info.rate)
+ if (ft1->signal.rate != ft2->signal.rate)
return ST_EOF;
- if (ft1->info.channels != ft2->info.channels)
+ if (ft1->signal.channels != ft2->signal.channels)
return ST_EOF;
return ST_SUCCESS;
@@ -575,11 +575,11 @@
for (f = 0; f < input_count; f++) {
st_report("Input file %s: using sample rate %lu\n\tsize %s, encoding %s, %d %s, volume %g",
- file_desc[f]->filename, file_desc[f]->info.rate,
- st_sizes_str[(unsigned char)file_desc[f]->info.size],
- st_encodings_str[(unsigned char)file_desc[f]->info.encoding],
- file_desc[f]->info.channels,
- (file_desc[f]->info.channels > 1) ? "channels" : "channel",
+ file_desc[f]->filename, file_desc[f]->signal.rate,
+ st_sizes_str[(unsigned char)file_desc[f]->signal.size],
+ st_encodings_str[(unsigned char)file_desc[f]->signal.encoding],
+ file_desc[f]->signal.channels,
+ (file_desc[f]->signal.channels > 1) ? "channels" : "channel",
file_opts[f]->volume == HUGE_VAL? 1 : file_opts[f]->volume);
if (file_desc[f]->comment)
@@ -589,7 +589,7 @@
for (f = 0; f < input_count; f++) {
if (combine_method == SOX_MERGE)
- file_desc[f]->info.channels *= input_count;
+ file_desc[f]->signal.channels *= input_count;
if (f && compare_input(file_desc[0], file_desc[f]) != ST_SUCCESS) {
st_fail("Input files must have the same rate and # of channels");
exit(1);
@@ -600,23 +600,23 @@
st_loopinfo_t loops[ST_MAX_NLOOPS];
double factor;
int i;
- file_options_t options = file_opts[file_count-1];
- char const * comment = NULL;
+ file_info_t info = file_opts[file_count - 1];
+ char const *comment = NULL;
- if (options->info.rate == 0)
- options->info.rate = file_desc[0]->info.rate;
- if (options->info.size == -1)
- options->info.size = file_desc[0]->info.size;
- if (options->info.encoding == ST_ENCODING_UNKNOWN)
- options->info.encoding = file_desc[0]->info.encoding;
- if (options->info.channels == 0)
- options->info.channels = file_desc[0]->info.channels;
+ if (info->signal.rate == 0)
+ info->signal.rate = file_desc[0]->signal.rate;
+ if (info->signal.size == -1)
+ info->signal.size = file_desc[0]->signal.size;
+ if (info->signal.encoding == ST_ENCODING_UNKNOWN)
+ info->signal.encoding = file_desc[0]->signal.encoding;
+ if (info->signal.channels == 0)
+ info->signal.channels = file_desc[0]->signal.channels;
- if (options->comment != NULL) {
- if (*options->comment == '\0')
- free(options->comment);
+ if (info->comment != NULL) {
+ if (*info->comment == '\0')
+ free(info->comment);
else
- comment = options->comment;
+ comment = info->comment;
} else
comment = file_desc[0]->comment ? file_desc[0]->comment : "Processed by SoX";
@@ -626,8 +626,8 @@
* FIXME: This doesn't work for multi-file processing or
* effects that change file length.
*/
- factor = (double) options->info.rate / (double)
- file_desc[0]->info.rate;
+ factor = (double) info->signal.rate / (double)
+ file_desc[0]->signal.rate;
for (i = 0; i < ST_MAX_NLOOPS; i++) {
loops[i].start = file_desc[0]->loops[i].start * factor;
loops[i].length = file_desc[0]->loops[i].length * factor;
@@ -637,9 +637,9 @@
file_desc[file_count - 1] =
st_open_write(overwrite_permitted,
- options->filename,
- &options->info,
- options->filetype,
+ info->filename,
+ &info->signal,
+ info->filetype,
comment,
&file_desc[0]->instr,
loops);
@@ -660,11 +660,11 @@
st_report("Output file %s: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
file_desc[file_count-1]->filename,
- file_desc[file_count-1]->info.rate,
- st_sizes_str[(unsigned char)file_desc[file_count-1]->info.size],
- st_encodings_str[(unsigned char)file_desc[file_count-1]->info.encoding],
- file_desc[file_count-1]->info.channels,
- (file_desc[file_count-1]->info.channels > 1) ? "channels" : "channel");
+ file_desc[file_count-1]->signal.rate,
+ st_sizes_str[(unsigned char)file_desc[file_count-1]->signal.size],
+ st_encodings_str[(unsigned char)file_desc[file_count-1]->signal.encoding],
+ file_desc[file_count-1]->signal.channels,
+ (file_desc[file_count-1]->signal.channels > 1) ? "channels" : "channel");
if (file_desc[file_count - 1]->comment)
st_report("Output file: comment \"%s\"",
@@ -673,7 +673,7 @@
/* Adjust the input rate for the speed effect */
for (f = 0; f < input_count; f++)
- file_desc[f]->info.rate = file_desc[f]->info.rate * globalinfo.speed + .5;
+ file_desc[f]->signal.rate = file_desc[f]->signal.rate * globalinfo.speed + .5;
/* build efftab */
check_effects();
@@ -697,7 +697,7 @@
if (combine_method == SOX_MERGE) {
alloc_size /= input_count;
- file_desc[f]->info.channels /= input_count;
+ file_desc[f]->signal.channels /= input_count;
}
ibuf[f] = (st_sample_t *)xmalloc(alloc_size);
@@ -949,8 +949,8 @@
user_efftab[j] = user_efftab[j + 1];
}
- needrate = (file_desc[0]->info.rate != file_desc[file_count-1]->info.rate);
- needchan = (file_desc[0]->info.channels != file_desc[file_count-1]->info.channels);
+ needrate = (file_desc[0]->signal.rate != file_desc[file_count-1]->signal.rate);
+ needchan = (file_desc[0]->signal.channels != file_desc[file_count-1]->signal.channels);
for (i = 0; i < nuser_effects; i++) {
if (user_efftab[i].h->flags & ST_EFF_CHAN)
@@ -975,7 +975,7 @@
* after the avg effect.
*/
if (needchan && !(haschan) &&
- (file_desc[0]->info.channels > file_desc[file_count-1]->info.channels))
+ (file_desc[0]->signal.channels > file_desc[file_count-1]->signal.channels))
{
/* Find effect and update initial pointers */
st_geteffect(&efftab[neffects], "avg");
@@ -990,8 +990,8 @@
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
- &file_desc[0]->info,
- &file_desc[file_count-1]->info,
+ &file_desc[0]->signal,
+ &file_desc[file_count-1]->signal,
effects_mask);
neffects++;
@@ -1001,7 +1001,7 @@
* after the resample effect.
*/
if (needrate && !(hasrate) &&
- (file_desc[0]->info.rate > file_desc[file_count-1]->info.rate))
+ (file_desc[0]->signal.rate > file_desc[file_count-1]->signal.rate))
{
st_geteffect(&efftab[neffects], "resample");
@@ -1015,8 +1015,8 @@
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
- &file_desc[0]->info,
- &file_desc[file_count-1]->info,
+ &file_desc[0]->signal,
+ &file_desc[file_count-1]->signal,
effects_mask);
/* Rate can't handle multiple channels so be sure and
@@ -1035,8 +1035,8 @@
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
- &file_desc[0]->info,
- &file_desc[file_count - 1]->info,
+ &file_desc[0]->signal,
+ &file_desc[file_count - 1]->signal,
effects_mask);
/* If this effect can't handle multiple channels then
@@ -1065,8 +1065,8 @@
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
- &file_desc[0]->info,
- &file_desc[file_count - 1]->info,
+ &file_desc[0]->signal,
+ &file_desc[file_count - 1]->signal,
effects_mask);
/* Rate can't handle multiple channels so be sure and
@@ -1091,8 +1091,8 @@
/* Copy format info to effect table */
effects_mask = st_updateeffect(&efftab[neffects],
- &file_desc[0]->info,
- &file_desc[file_count - 1]->info,
+ &file_desc[0]->signal,
+ &file_desc[file_count - 1]->signal,
effects_mask);
neffects++;
@@ -1180,12 +1180,12 @@
}
total += len;
} while (total < efftab[neffects-1].olen);
- output_samples += (total / file_desc[file_count - 1]->info.channels);
+ output_samples += (total / file_desc[file_count - 1]->signal.channels);
efftab[neffects-1].odone = efftab[neffects-1].olen = 0;
} else {
/* Make it look like everything was consumed */
output_samples += (efftab[neffects-1].olen /
- file_desc[file_count - 1]->info.channels);
+ file_desc[file_count - 1]->signal.channels);
efftab[neffects-1].odone = efftab[neffects-1].olen = 0;
}
@@ -1209,7 +1209,7 @@
* will cause stereo channels to be inversed.
*/
if ((efftab[e].olen - efftab[e].odone) >=
- file_desc[file_count - 1]->info.channels)
+ file_desc[file_count - 1]->signal.channels)
havedata = 1;
else
st_warn("Received buffer with incomplete amount of samples.");
@@ -1457,12 +1457,12 @@
{
fprintf(stderr, "\nInput Filename : %s\n", file_desc[input]->filename);
fprintf(stderr, "Sample Size : %s\n",
- st_size_bits_str[file_desc[input]->info.size]);
+ st_size_bits_str[file_desc[input]->signal.size]);
fprintf(stderr, "Sample Encoding: %s\n",
- st_encodings_str[file_desc[input]->info.encoding]);
- fprintf(stderr, "Channels : %d\n", file_desc[input]->info.channels);
+ st_encodings_str[file_desc[input]->signal.encoding]);
+ fprintf(stderr, "Channels : %d\n", file_desc[input]->signal.channels);
fprintf(stderr, "Sample Rate : %d\n",
- (int)(file_desc[input]->info.rate / globalinfo.speed + 0.5));
+ (int)(file_desc[input]->signal.rate / globalinfo.speed + 0.5));
if (file_desc[input]->comment && *file_desc[input]->comment)
fprintf(stderr, "Comments :\n%s\n", file_desc[input]->comment);
@@ -1481,8 +1481,8 @@
/* Currently, for all sox modes, all input files must have
* the same sample rate. So we can always just use the rate
* of the first input file to compute time. */
- read_time = (double)read_samples / (double)file_desc[0]->info.rate /
- (double)file_desc[0]->info.channels;
+ read_time = (double)read_samples / (double)file_desc[0]->signal.rate /
+ (double)file_desc[0]->signal.channels;
read_min = read_time / 60;
read_sec = (double)read_time - 60.0f * (double)read_min;
@@ -1504,8 +1504,8 @@
}
if (input_samples) {
- in_time = (double)input_samples / (double)file_desc[0]->info.rate /
- (double)file_desc[0]->info.channels;
+ in_time = (double)input_samples / (double)file_desc[0]->signal.rate /
+ (double)file_desc[0]->signal.channels;
left_time = in_time - read_time;
if (left_time < 0)
left_time = 0;
@@ -1529,7 +1529,7 @@
}
/* Adjust volume based on value specified by the -v option for this file. */
-static void volumechange(st_sample_t * buf, st_ssize_t len, file_options_t fo)
+static void volumechange(st_sample_t * buf, st_ssize_t len, file_info_t fo)
{
if (fo->volume != HUGE_VAL && fo->volume != 1)
while (len--) {
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -72,16 +72,16 @@
while (strncmp(buf, "end_head", 8) != 0)
{
- if (strncmp(buf, "sample_n_bytes", 14) == 0 && ft->info.size == -1)
+ if (strncmp(buf, "sample_n_bytes", 14) == 0 && ft->signal.size == -1)
{
sscanf(buf, "%63s %15s %d", fldname, fldtype, &i);
- ft->info.size = i;
+ ft->signal.size = i;
}
if (strncmp(buf, "channel_count", 13) == 0 &&
- ft->info.channels == 0)
+ ft->signal.channels == 0)
{
sscanf(buf, "%63s %15s %d", fldname, fldtype, &i);
- ft->info.channels = i;
+ ft->signal.channels = i;
}
if (strncmp(buf, "sample_coding", 13) == 0)
{
@@ -89,25 +89,25 @@
/* Only bother looking for ulaw flag. All others
* should be caught below by default PCM check
*/
- if (ft->info.encoding == ST_ENCODING_UNKNOWN &&
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN &&
strncmp(fldsval,"ulaw",4) == 0)
{
- ft->info.encoding = ST_ENCODING_ULAW;
+ ft->signal.encoding = ST_ENCODING_ULAW;
}
}
if (strncmp(buf, "sample_rate ", 12) == 0 &&
- ft->info.rate == 0)
+ ft->signal.rate == 0)
{
sscanf(buf, "%53s %15s %ld", fldname, fldtype, &rate);
- ft->info.rate = rate;
+ ft->signal.rate = rate;
}
if (strncmp(buf, "sample_byte_format", 18) == 0)
{
sscanf(buf, "%53s %15s %127s", fldname, fldtype, fldsval);
if (strncmp(fldsval,"01",2) == 0)
- ft->info.swap_bytes = ST_IS_BIGENDIAN; /* Data is little endian. */
+ ft->signal.swap_bytes = ST_IS_BIGENDIAN; /* Data is little endian. */
else if (strncmp(fldsval,"10",2) == 0)
- ft->info.swap_bytes = ST_IS_LITTLEENDIAN; /* Data is big endian. */
+ ft->signal.swap_bytes = ST_IS_LITTLEENDIAN; /* Data is big endian. */
}
if (st_reads(ft, buf, header_size) == ST_EOF)
@@ -120,19 +120,19 @@
header_size -= (strlen(buf) + 1);
}
- if (ft->info.size == -1)
- ft->info.size = ST_SIZE_BYTE;
+ if (ft->signal.size == -1)
+ ft->signal.size = ST_SIZE_BYTE;
/* sample_coding is optional and is PCM if missing.
* This means encoding is signed if size = word or
* unsigned if size = byte.
*/
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
{
- if (ft->info.size == 1)
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ if (ft->signal.size == 1)
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
else
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
while (header_size)
@@ -197,7 +197,7 @@
return (ST_EOF);
}
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_ULAW:
case ST_ENCODING_SIGN2:
@@ -252,25 +252,25 @@
st_writes(ft, "NIST_1A\n");
st_writes(ft, " 1024\n");
- samples = sphere->numSamples/ft->info.channels;
+ samples = sphere->numSamples/ft->signal.channels;
sprintf(buf, "sample_count -i %ld\n", samples);
st_writes(ft, buf);
- sprintf(buf, "sample_n_bytes -i %d\n", ft->info.size);
+ sprintf(buf, "sample_n_bytes -i %d\n", ft->signal.size);
st_writes(ft, buf);
- sprintf(buf, "channel_count -i %d\n", ft->info.channels);
+ sprintf(buf, "channel_count -i %d\n", ft->signal.channels);
st_writes(ft, buf);
sprintf(buf, "sample_byte_format -s2 %s\n",
- ft->info.swap_bytes != ST_IS_BIGENDIAN ? "10" : "01");
+ ft->signal.swap_bytes != ST_IS_BIGENDIAN ? "10" : "01");
st_writes(ft, buf);
- rate = ft->info.rate;
+ rate = ft->signal.rate;
sprintf(buf, "sample_rate -i %ld\n", rate);
st_writes(ft, buf);
- if (ft->info.encoding == ST_ENCODING_ULAW)
+ if (ft->signal.encoding == ST_ENCODING_ULAW)
st_writes(ft, "sample_coding -s4 ulaw\n");
else
st_writes(ft, "sample_coding -s3 pcm\n");
--- a/src/st.h
+++ b/src/st.h
@@ -281,7 +281,7 @@
} st_format_t;
struct st_soundstream {
- st_signalinfo_t info; /* signal specifications */
+ st_signalinfo_t signal; /* signal specifications */
st_instrinfo_t instr; /* instrument specification */
st_loopinfo_t loops[ST_MAX_NLOOPS]; /* Looping specification */
char seekable; /* can seek on this file */
--- a/src/stio.c
+++ b/src/stio.c
@@ -27,11 +27,11 @@
void set_swap_if_not_already_set(ft_t ft)
{
- if (ft->info.swap_bytes == ST_SWAP_DEFAULT) {
+ if (ft->signal.swap_bytes == ST_SWAP_DEFAULT) {
if (ft->h->flags & ST_FILE_ENDIAN)
- ft->info.swap_bytes = ST_IS_LITTLEENDIAN != !(ft->h->flags & ST_FILE_ENDBIG);
+ ft->signal.swap_bytes = ST_IS_LITTLEENDIAN != !(ft->h->flags & ST_FILE_ENDBIG);
else
- ft->info.swap_bytes = ST_SWAP_NO;
+ ft->signal.swap_bytes = ST_SWAP_NO;
}
}
@@ -50,31 +50,31 @@
ft->st_errno = ST_SUCCESS;
- if (ft->info.rate == 0)
+ if (ft->signal.rate == 0)
{
st_fail_errno(ft,ST_EFMT,"sampling rate was not specified");
return ST_EOF;
}
- if (ft->info.size == -1)
+ if (ft->signal.size == -1)
{
st_fail_errno(ft,ST_EFMT,"data size was not specified");
return ST_EOF;
}
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
{
st_fail_errno(ft,ST_EFMT,"data encoding was not specified");
return ST_EOF;
}
- if ((ft->info.size <= 0) || (ft->info.size > ST_INFO_SIZE_MAX))
+ if ((ft->signal.size <= 0) || (ft->signal.size > ST_INFO_SIZE_MAX))
{
st_fail_errno(ft,ST_EFMT,"data size %i is invalid");
return ST_EOF;
}
- if (ft->info.encoding <= 0 || ft->info.encoding >= ST_ENCODINGS)
+ if (ft->signal.encoding <= 0 || ft->signal.encoding >= ST_ENCODINGS)
{
st_fail_errno(ft,ST_EFMT,"data encoding %i is invalid");
return ST_EOF;
@@ -103,11 +103,11 @@
goto input_error;
}
- ft->info.size = -1;
- ft->info.encoding = ST_ENCODING_UNKNOWN;
- ft->info.channels = 0;
+ ft->signal.size = -1;
+ ft->signal.encoding = ST_ENCODING_UNKNOWN;
+ ft->signal.channels = 0;
if (info)
- ft->info = *info;
+ ft->signal = *info;
ft->mode = 'r';
if (!(ft->h->flags & ST_FILE_NOSTDIO))
@@ -145,8 +145,8 @@
* This is because libst usually doesn't set this for mono file
* formats (for historical reasons).
*/
- if (ft->info.channels == 0)
- ft->info.channels = 1;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = 1;
if (st_checkformat(ft) )
{
@@ -215,11 +215,11 @@
goto output_error;
}
- ft->info.size = -1;
- ft->info.encoding = ST_ENCODING_UNKNOWN;
- ft->info.channels = 0;
+ ft->signal.size = -1;
+ ft->signal.encoding = ST_ENCODING_UNKNOWN;
+ ft->signal.channels = 0;
if (info)
- ft->info = *info;
+ ft->signal = *info;
ft->mode = 'w';
if (!(ft->h->flags & ST_FILE_NOSTDIO))
@@ -296,10 +296,10 @@
st_size_t st_read(ft_t ft, st_sample_t *buf, st_size_t len)
{
- len -= len % ft->info.channels; /* We need a whole number of "wide" samples */
+ len -= len % ft->signal.channels; /* We need a whole number of "wide" samples */
len = (*ft->h->read)(ft, buf, len);
if (len != ST_EOF)
- len -= len % ft->info.channels; /* Belt & braces */
+ len -= len % ft->signal.channels; /* Belt & braces */
return len;
}
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -135,13 +135,13 @@
switch( sample_rate ) {
case 1:
- ft->info.rate = 33333;
+ ft->signal.rate = 33333;
break;
case 2:
- ft->info.rate = 50000;
+ ft->signal.rate = 50000;
break;
case 3:
- ft->info.rate = 16667;
+ ft->signal.rate = 16667;
break;
default:
blewIt = 1;
@@ -149,32 +149,32 @@
case 0x06:
if ( (gunk[5] & 0xFE) == 0x52 ) {
blewIt = 0;
- ft->info.rate = 33333;
+ ft->signal.rate = 33333;
}
break;
case 0x10:
if ( (gunk[5] & 0xFE) == 0x00 ) {
blewIt = 0;
- ft->info.rate = 50000;
+ ft->signal.rate = 50000;
}
break;
case 0xF6:
if ( (gunk[5] & 0xFE) == 0x52 ) {
blewIt = 0;
- ft->info.rate = 16667;
+ ft->signal.rate = 16667;
}
break;
}
if ( blewIt ) {
st_debug("Invalid sample rate identifier found %d", (int)sample_rate);
- ft->info.rate = 33333;
+ ft->signal.rate = 33333;
}
}
- st_debug("Sample rate = %ld",ft->info.rate);
+ st_debug("Sample rate = %ld",ft->signal.rate);
- ft->info.channels = 1 ; /* not sure about stereo sample data yet ??? */
- ft->info.size = ST_SIZE_WORD; /* this is close enough */
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.channels = 1 ; /* not sure about stereo sample data yet ??? */
+ ft->signal.size = ST_SIZE_WORD; /* this is close enough */
+ ft->signal.encoding = ST_ENCODING_SIGN2;
return(ST_SUCCESS);
}
@@ -244,13 +244,13 @@
memset(&WH, 0, sizeof(struct WaveHeader_));
- if (ft->info.channels != 1)
+ if (ft->signal.channels != 1)
st_report("tx16w is overriding output format to 1 channel.");
- ft->info.channels = 1 ; /* not sure about stereo sample data yet ??? */
- if (ft->info.size != ST_SIZE_WORD || ft->info.encoding != ST_ENCODING_SIGN2)
+ ft->signal.channels = 1 ; /* not sure about stereo sample data yet ??? */
+ if (ft->signal.size != ST_SIZE_WORD || ft->signal.encoding != ST_ENCODING_SIGN2)
st_report("tx16w is overriding output format to size Signed Word format.");
- ft->info.size = ST_SIZE_WORD; /* this is close enough */
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD; /* this is close enough */
+ ft->signal.encoding = ST_ENCODING_SIGN2;
/* If you have to seek around the output file */
if (! ft->seekable)
@@ -312,8 +312,8 @@
WH.format = 0xC9; /* loop off */
/* the actual sample rate is not that important ! */
- if (ft->info.rate < 24000) WH.sample_rate = 3;
- else if (ft->info.rate < 41000) WH.sample_rate = 1;
+ if (ft->signal.rate < 24000) WH.sample_rate = 3;
+ else if (ft->signal.rate < 41000) WH.sample_rate = 1;
else WH.sample_rate = 2;
if (tx16w_len >= TXMAXLEN) {
--- a/src/voc.c
+++ b/src/voc.c
@@ -258,12 +258,12 @@
}
/* setup word length of data */
- ft->info.size = v->size;
+ ft->signal.size = v->size;
/* ANN: Check VOC format and map to the proper ST format value */
switch (v->format) {
case VOC_FMT_LIN8U: /* 0 8 bit unsigned linear PCM */
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
break;
case VOC_FMT_CRLADPCM4: /* 1 Creative 8-bit to 4-bit ADPCM */
st_fail ("Unsupported VOC format CRLADPCM4 %d", v->format);
@@ -278,13 +278,13 @@
rtn=ST_EOF;
break;
case VOC_FMT_LIN16: /* 4 16-bit signed PCM */
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
break;
case VOC_FMT_ALAW: /* 6 CCITT a-Law 8-bit PCM */
- ft->info.encoding = ST_ENCODING_ALAW;
+ ft->signal.encoding = ST_ENCODING_ALAW;
break;
case VOC_FMT_MU255: /* 7 CCITT u-Law 8-bit PCM */
- ft->info.encoding = ST_ENCODING_ULAW;
+ ft->signal.encoding = ST_ENCODING_ULAW;
break;
case VOC_FMT_CRLADPCM4A: /*0x200 Creative 16-bit to 4-bit ADPCM */
st_fail ("Unsupported VOC format CRLADPCM4A %d", v->format);
@@ -297,8 +297,8 @@
}
/* setup number of channels */
- if (ft->info.channels == 0)
- ft->info.channels = v->channels;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = v->channels;
return(ST_SUCCESS);
}
@@ -428,12 +428,12 @@
st_writew(ft, 0x10a); /* major/minor version number */
st_writew(ft, 0x1129); /* checksum of version number */
- if (ft->info.size == ST_SIZE_BYTE)
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ if (ft->signal.size == ST_SIZE_BYTE)
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
else
- ft->info.encoding = ST_ENCODING_SIGN2;
- if (ft->info.channels == 0)
- ft->info.channels = 1;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.channels == 0)
+ ft->signal.channels = 1;
return(ST_SUCCESS);
}
@@ -455,7 +455,7 @@
}
v->samples += len;
while(done < len) {
- if (ft->info.size == ST_SIZE_BYTE) {
+ if (ft->signal.size == ST_SIZE_BYTE) {
uc = ST_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clippedCount);
st_writeb(ft, uc);
} else {
@@ -482,17 +482,17 @@
if (v->silent) {
st_writew(ft, v->samples);
} else {
- if (ft->info.size == ST_SIZE_BYTE) {
- if (ft->info.channels > 1) {
+ if (ft->signal.size == ST_SIZE_BYTE) {
+ if (ft->signal.channels > 1) {
st_seeki(ft, 8, 1); /* forward 7 + 1 for new block header */
}
}
v->samples += 2; /* adjustment: SBDK pp. 3-5 */
- datum = (v->samples * ft->info.size) & 0xff;
+ datum = (v->samples * ft->signal.size) & 0xff;
st_writeb(ft, (int)datum); /* low byte of length */
- datum = ((v->samples * ft->info.size) >> 8) & 0xff;
+ datum = ((v->samples * ft->signal.size) >> 8) & 0xff;
st_writeb(ft, (int)datum); /* middle byte of length */
- datum = ((v->samples * ft->info.size)>> 16) & 0xff;
+ datum = ((v->samples * ft->signal.size)>> 16) & 0xff;
st_writeb(ft, (int)datum); /* high byte of length */
}
}
@@ -577,7 +577,7 @@
return(ST_EOF);
}
v->rate = uc;
- ft->info.rate = 1000000.0/(256 - v->rate);
+ ft->signal.rate = 1000000.0/(256 - v->rate);
v->channels = 1;
}
st_readb(ft, &uc);
@@ -608,7 +608,7 @@
return(ST_EOF);
}
v->rate = new_rate_32;
- ft->info.rate = new_rate_32;
+ ft->signal.rate = new_rate_32;
st_readb(ft, &uc);
switch (uc)
{
@@ -725,11 +725,11 @@
}
st_readb(ft, &uc);
if (uc)
- ft->info.channels = 2; /* Stereo */
+ ft->signal.channels = 2; /* Stereo */
/* Needed number of channels before finishing
compute for rate */
- ft->info.rate = (256000000L/(65536L - v->rate))/
- ft->info.channels;
+ ft->signal.rate = (256000000L/(65536L - v->rate))/
+ ft->signal.channels;
/* An extended block must be followed by a data */
/* block to be valid so loop back to top so it */
/* can be grabed. */
@@ -758,7 +758,7 @@
st_writeb(ft, 0); /* Period length */
st_writeb(ft, v->rate); /* Rate code */
} else {
- if (ft->info.size == ST_SIZE_BYTE) {
+ if (ft->signal.size == ST_SIZE_BYTE) {
/* 8-bit sample section. By always setting the correct */
/* rate value in the DATA block (even when its preceeded */
/* by an EXTENDED block) old software can still play stereo */
@@ -765,12 +765,12 @@
/* files in mono by just skipping over the EXTENDED block. */
/* Prehaps the rate should be doubled though to make up for */
/* double amount of samples for a given time???? */
- if (ft->info.channels > 1) {
+ if (ft->signal.channels > 1) {
st_writeb(ft, VOC_EXTENDED); /* Voice Extended block code */
st_writeb(ft, 4); /* block length = 4 */
st_writeb(ft, 0); /* block length = 4 */
st_writeb(ft, 0); /* block length = 4 */
- v->rate = 65536L - (256000000.0/(2*(float)ft->info.rate));
+ v->rate = 65536L - (256000000.0/(2*(float)ft->signal.rate));
st_writew(ft,v->rate); /* Rate code */
st_writeb(ft, 0); /* File is not packed */
st_writeb(ft, 1); /* samples are in stereo */
@@ -779,7 +779,7 @@
st_writeb(ft, 0); /* block length (for now) */
st_writeb(ft, 0); /* block length (for now) */
st_writeb(ft, 0); /* block length (for now) */
- v->rate = 256 - (1000000.0/(float)ft->info.rate);
+ v->rate = 256 - (1000000.0/(float)ft->signal.rate);
st_writeb(ft, (int) v->rate);/* Rate code */
st_writeb(ft, 0); /* 8-bit raw data */
} else {
@@ -787,10 +787,10 @@
st_writeb(ft, 0); /* block length (for now) */
st_writeb(ft, 0); /* block length (for now) */
st_writeb(ft, 0); /* block length (for now) */
- v->rate = ft->info.rate;
+ v->rate = ft->signal.rate;
st_writedw(ft, v->rate); /* Rate code */
st_writeb(ft, 16); /* Sample Size */
- st_writeb(ft, ft->info.channels); /* Sample Size */
+ st_writeb(ft, ft->signal.channels); /* Sample Size */
st_writew(ft, 0x0004); /* Encoding */
st_writeb(ft, 0); /* Unused */
st_writeb(ft, 0); /* Unused */
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -120,10 +120,10 @@
vc = ov_comment(vb->vf, -1);
/* Record audio info */
- ft->info.rate = vi->rate;
- ft->info.size = ST_SIZE_16BIT;
- ft->info.encoding = ST_ENCODING_VORBIS;
- ft->info.channels = vi->channels;
+ ft->signal.rate = vi->rate;
+ ft->signal.size = ST_SIZE_16BIT;
+ ft->signal.encoding = ST_ENCODING_VORBIS;
+ ft->signal.channels = vi->channels;
/* ov_pcm_total doesn't work on non-seekable files so
* skip that step in that case. Also, it reports
@@ -130,7 +130,7 @@
* "frame"-ish results so we must * channels.
*/
if (ft->seekable)
- ft->length = ov_pcm_total(vb->vf, -1) * ft->info.channels;
+ ft->length = ov_pcm_total(vb->vf, -1) * ft->signal.channels;
/* Record comments */
if (vc->comments == 0)
@@ -336,8 +336,8 @@
long rate;
double quality = 3; /* Default compression quality gives ~112kbps */
- ft->info.size = ST_SIZE_16BIT;
- ft->info.encoding = ST_ENCODING_VORBIS;
+ ft->signal.size = ST_SIZE_16BIT;
+ ft->signal.encoding = ST_ENCODING_VORBIS;
/* Allocate memory for all of the structures */
ve = vb->vorbis_enc_data = (vorbis_enc_t *)xmalloc(sizeof(vorbis_enc_t));
@@ -345,22 +345,22 @@
vorbis_info_init(&ve->vi);
/* TODO */
- rate = ft->info.rate;
+ rate = ft->signal.rate;
if (rate)
st_fail_errno(ft, ST_EHDR, "Error setting up Ogg Vorbis encorder - make sure you've specied a sane rate and number of channels");
/* Use encoding to average bit rate of VBR as specified by the -C option */
- if (ft->info.compression != HUGE_VAL)
+ if (ft->signal.compression != HUGE_VAL)
{
- if (ft->info.compression < -1 || ft->info.compression > 10)
+ if (ft->signal.compression < -1 || ft->signal.compression > 10)
{
st_fail_errno(ft,ST_EINVAL,
"Vorbis compression quality nust be between -1 and 10");
return ST_EOF;
}
- quality = ft->info.compression;
+ quality = ft->signal.compression;
}
- vorbis_encode_init_vbr(&ve->vi, ft->info.channels, ft->info.rate, quality / 10);
+ vorbis_encode_init_vbr(&ve->vi, ft->signal.channels, ft->signal.rate, quality / 10);
vorbis_analysis_init(&ve->vd, &ve->vi);
vorbis_block_init(&ve->vd, &ve->vb);
@@ -381,7 +381,7 @@
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve = vb->vorbis_enc_data;
- st_size_t samples = len / ft->info.channels;
+ st_size_t samples = len / ft->signal.channels;
float **buffer = vorbis_analysis_buffer(&ve->vd, samples);
st_size_t i, j;
int ret;
@@ -389,8 +389,8 @@
/* Copy samples into vorbis buffer */
for (i = 0; i < samples; i++)
- for (j = 0; j < ft->info.channels; j++)
- buffer[j][i] = buf[i*ft->info.channels + j]
+ for (j = 0; j < ft->signal.channels; j++)
+ buffer[j][i] = buf[i*ft->signal.channels + j]
/ ((float)ST_SAMPLE_MAX);
vorbis_analysis_wrote(&ve->vd, samples);
--- a/src/vox.c
+++ b/src/vox.c
@@ -93,12 +93,12 @@
state->file.pos = 0;
state->file.eof = 0;
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_OKI_ADPCM;
- ft->info.channels = 1;
- if (ft->info.rate == 0) {
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_OKI_ADPCM;
+ ft->signal.channels = 1;
+ if (ft->signal.rate == 0) {
st_warn("'%s': sample rate not specified; trying 8kHz", ft->filename);
- ft->info.rate = 8000;
+ ft->signal.rate = 8000;
}
/* ... initialise CODEC state */
@@ -208,9 +208,9 @@
state->file.pos = 0;
state->file.eof = 0;
- ft->info.size = ST_SIZE_WORD;
- ft->info.encoding = ST_ENCODING_OKI_ADPCM;
- ft->info.channels = 1;
+ ft->signal.size = ST_SIZE_WORD;
+ ft->signal.encoding = ST_ENCODING_OKI_ADPCM;
+ ft->signal.channels = 1;
/* ... initialise CODEC state */
--- a/src/wav.c
+++ b/src/wav.c
@@ -88,7 +88,7 @@
/* If it looks like a valid header is around then try and */
/* work with partial blocks. Specs say it should be null */
/* padded but I guess this is better than trailing quiet. */
- samplesThisBlock = ImaSamplesIn(0, ft->info.channels, bytesRead, 0);
+ samplesThisBlock = ImaSamplesIn(0, ft->signal.channels, bytesRead, 0);
if (samplesThisBlock == 0)
{
st_warn("Premature EOF on .wav input file");
@@ -100,7 +100,7 @@
/* For a full block, the following should be true: */
/* wav->samplesPerBlock = blockAlign - 8byte header + 1 sample in header */
- ImaBlockExpandI(ft->info.channels, wav->packet, wav->samples, samplesThisBlock);
+ ImaBlockExpandI(ft->signal.channels, wav->packet, wav->samples, samplesThisBlock);
return samplesThisBlock;
}
@@ -129,7 +129,7 @@
/* If it looks like a valid header is around then try and */
/* work with partial blocks. Specs say it should be null */
/* padded but I guess this is better than trailing quiet. */
- samplesThisBlock = AdpcmSamplesIn(0, ft->info.channels, bytesRead, 0);
+ samplesThisBlock = AdpcmSamplesIn(0, ft->signal.channels, bytesRead, 0);
if (samplesThisBlock == 0)
{
st_warn("Premature EOF on .wav input file");
@@ -137,7 +137,7 @@
}
}
- errmsg = AdpcmBlockExpandI(ft->info.channels, wav->nCoefs, wav->iCoefs, wav->packet, wav->samples, samplesThisBlock);
+ errmsg = AdpcmBlockExpandI(ft->signal.channels, wav->nCoefs, wav->iCoefs, wav->packet, wav->samples, samplesThisBlock);
if (errmsg)
st_warn((char*)errmsg);
@@ -155,7 +155,7 @@
int chans, ct;
short *p;
- chans = ft->info.channels;
+ chans = ft->signal.channels;
p = wav->samplePtr;
ct = p - wav->samples;
if (ct>=chans) {
@@ -408,7 +408,7 @@
if (strncmp("RIFX", magic, 4) == 0)
{
st_debug("Found RIFX header, swapping bytes");
- ft->info.swap_bytes = ST_IS_LITTLEENDIAN;
+ ft->signal.swap_bytes = ST_IS_LITTLEENDIAN;
}
st_readdw(ft, &dwRiffLength);
@@ -483,8 +483,8 @@
case WAVE_FORMAT_PCM:
/* Default (-1) depends on sample size. Set that later on. */
- if (ft->info.encoding != ST_ENCODING_UNKNOWN && ft->info.encoding != ST_ENCODING_UNSIGNED &&
- ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_UNSIGNED &&
+ ft->signal.encoding != ST_ENCODING_SIGN2)
st_report("User options overriding encoding read in .wav header");
/* Needed by rawread() functions */
@@ -495,22 +495,22 @@
break;
case WAVE_FORMAT_IMA_ADPCM:
- if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_IMA_ADPCM)
- ft->info.encoding = ST_ENCODING_IMA_ADPCM;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_IMA_ADPCM)
+ ft->signal.encoding = ST_ENCODING_IMA_ADPCM;
else
st_report("User options overriding encoding read in .wav header");
break;
case WAVE_FORMAT_ADPCM:
- if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_ADPCM)
- ft->info.encoding = ST_ENCODING_ADPCM;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_ADPCM)
+ ft->signal.encoding = ST_ENCODING_ADPCM;
else
st_report("User options overriding encoding read in .wav header");
break;
case WAVE_FORMAT_IEEE_FLOAT:
- if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_FLOAT)
- ft->info.encoding = ST_ENCODING_FLOAT;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_FLOAT)
+ ft->signal.encoding = ST_ENCODING_FLOAT;
else
st_report("User options overriding encoding read in .wav header");
@@ -522,8 +522,8 @@
break;
case WAVE_FORMAT_ALAW:
- if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_ALAW)
- ft->info.encoding = ST_ENCODING_ALAW;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_ALAW)
+ ft->signal.encoding = ST_ENCODING_ALAW;
else
st_report("User options overriding encoding read in .wav header");
@@ -535,8 +535,8 @@
break;
case WAVE_FORMAT_MULAW:
- if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_ULAW)
- ft->info.encoding = ST_ENCODING_ULAW;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_ULAW)
+ ft->signal.encoding = ST_ENCODING_ULAW;
else
st_report("User options overriding encoding read in .wav header");
@@ -560,8 +560,8 @@
st_fail_errno(ft,ST_EHDR,"Sorry, this WAV file is in Dolby AC2 format.");
return ST_EOF;
case WAVE_FORMAT_GSM610:
- if (ft->info.encoding == ST_ENCODING_UNKNOWN || ft->info.encoding == ST_ENCODING_GSM )
- ft->info.encoding = ST_ENCODING_GSM;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_GSM )
+ ft->signal.encoding = ST_ENCODING_GSM;
else
st_report("User options overriding encoding read in .wav header");
break;
@@ -594,13 +594,13 @@
}
/* User options take precedence */
- if (ft->info.channels == 0 || ft->info.channels == wChannels)
- ft->info.channels = wChannels;
+ if (ft->signal.channels == 0 || ft->signal.channels == wChannels)
+ ft->signal.channels = wChannels;
else
st_report("User options overriding channels read in .wav header");
- if (ft->info.rate == 0 || ft->info.rate == dwSamplesPerSecond)
- ft->info.rate = dwSamplesPerSecond;
+ if (ft->signal.rate == 0 || ft->signal.rate == dwSamplesPerSecond)
+ ft->signal.rate = dwSamplesPerSecond;
else
st_report("User options overriding rate read in .wav header");
@@ -646,7 +646,7 @@
}
st_readw(ft, &(wav->samplesPerBlock));
- bytesPerBlock = AdpcmBytesPerBlock(ft->info.channels, wav->samplesPerBlock);
+ bytesPerBlock = AdpcmBytesPerBlock(ft->signal.channels, wav->samplesPerBlock);
if (bytesPerBlock > wav->blockAlign)
{
st_fail_errno(ft,ST_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
@@ -702,7 +702,7 @@
}
st_readw(ft, &(wav->samplesPerBlock));
- bytesPerBlock = ImaBytesPerBlock(ft->info.channels, wav->samplesPerBlock);
+ bytesPerBlock = ImaBytesPerBlock(ft->signal.channels, wav->samplesPerBlock);
if (bytesPerBlock > wav->blockAlign || wav->samplesPerBlock%8 != 1)
{
st_fail_errno(ft,ST_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
@@ -754,47 +754,47 @@
case ST_SIZE_BYTE:
/* User options take precedence */
- if (ft->info.size == -1 || ft->info.size == ST_SIZE_BYTE)
- ft->info.size = ST_SIZE_BYTE;
+ if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_BYTE)
+ ft->signal.size = ST_SIZE_BYTE;
else
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
break;
case ST_SIZE_WORD:
- if (ft->info.size == -1 || ft->info.size == ST_SIZE_WORD)
- ft->info.size = ST_SIZE_WORD;
+ if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_WORD)
+ ft->signal.size = ST_SIZE_WORD;
else
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
- ft->info.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ ft->signal.encoding = ST_ENCODING_SIGN2;
break;
case ST_SIZE_24BIT:
- if (ft->info.size == -1 || ft->info.size == ST_SIZE_24BIT)
- ft->info.size = ST_SIZE_24BIT;
+ if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_24BIT)
+ ft->signal.size = ST_SIZE_24BIT;
else
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
- ft->info.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ ft->signal.encoding = ST_ENCODING_SIGN2;
break;
case ST_SIZE_DWORD:
- if (ft->info.size == -1 || ft->info.size == ST_SIZE_DWORD)
- ft->info.size = ST_SIZE_DWORD;
+ if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_DWORD)
+ ft->signal.size = ST_SIZE_DWORD;
else
st_warn("User options overriding size read in .wav header");
/* Now we have enough information to set default encodings. */
- if (ft->info.encoding == ST_ENCODING_UNKNOWN)
- ft->info.encoding = ST_ENCODING_SIGN2;
+ if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+ ft->signal.encoding = ST_ENCODING_SIGN2;
break;
default:
@@ -824,11 +824,11 @@
case WAVE_FORMAT_ADPCM:
wav->numSamples =
- AdpcmSamplesIn(dwDataLength, ft->info.channels,
+ AdpcmSamplesIn(dwDataLength, ft->signal.channels,
wav->blockAlign, wav->samplesPerBlock);
/*st_debug("datalen %d, numSamples %d",dwDataLength, wav->numSamples);*/
wav->blockSamplesRemaining = 0; /* Samples left in buffer */
- ft->length = wav->numSamples*ft->info.channels;
+ ft->length = wav->numSamples*ft->signal.channels;
break;
case WAVE_FORMAT_IMA_ADPCM:
@@ -835,27 +835,27 @@
/* Compute easiest part of number of samples. For every block, there
are samplesPerBlock samples to read. */
wav->numSamples =
- ImaSamplesIn(dwDataLength, ft->info.channels,
+ ImaSamplesIn(dwDataLength, ft->signal.channels,
wav->blockAlign, wav->samplesPerBlock);
/*st_debug("datalen %d, numSamples %d",dwDataLength, wav->numSamples);*/
wav->blockSamplesRemaining = 0; /* Samples left in buffer */
initImaTable();
- ft->length = wav->numSamples*ft->info.channels;
+ ft->length = wav->numSamples*ft->signal.channels;
break;
case WAVE_FORMAT_GSM610:
wav->numSamples = ((dwDataLength / wav->blockAlign) * wav->samplesPerBlock);
wavgsminit(ft);
- ft->length = wav->numSamples*ft->info.channels;
+ ft->length = wav->numSamples*ft->signal.channels;
break;
default:
- wav->numSamples = dwDataLength/ft->info.size/ft->info.channels;
- ft->length = wav->numSamples*ft->info.channels;
+ wav->numSamples = dwDataLength/ft->signal.size/ft->signal.channels;
+ ft->length = wav->numSamples*ft->signal.channels;
}
st_debug("Reading Wave file: %s format, %d channel%s, %d samp/sec",
- wav_format_str(wav->formatTag), ft->info.channels,
+ wav_format_str(wav->formatTag), ft->signal.channels,
wChannels == 1 ? "" : "s", dwSamplesPerSecond);
st_debug(" %d byte/sec, %d block align, %d bits/samp, %u data bytes",
dwAvgBytesPerSec, wav->blockAlign, wBitsPerSample, dwDataLength);
@@ -1008,14 +1008,14 @@
/* If file is in ADPCM encoding then read in multiple blocks else */
/* read as much as possible and return quickly. */
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_IMA_ADPCM:
case ST_ENCODING_ADPCM:
/* See reason for cooledit check in comments below */
- if (wav->found_cooledit && len > (wav->numSamples*ft->info.channels))
- len = (wav->numSamples*ft->info.channels);
+ if (wav->found_cooledit && len > (wav->numSamples*ft->signal.channels))
+ len = (wav->numSamples*ft->signal.channels);
done = 0;
while (done < len) { /* Still want data? */
@@ -1039,11 +1039,11 @@
short *p, *top;
size_t ct;
ct = len-done;
- if (ct > (wav->blockSamplesRemaining*ft->info.channels))
- ct = (wav->blockSamplesRemaining*ft->info.channels);
+ if (ct > (wav->blockSamplesRemaining*ft->signal.channels))
+ ct = (wav->blockSamplesRemaining*ft->signal.channels);
done += ct;
- wav->blockSamplesRemaining -= (ct/ft->info.channels);
+ wav->blockSamplesRemaining -= (ct/ft->signal.channels);
p = wav->samplePtr;
top = p+ct;
/* Output is already signed */
@@ -1057,14 +1057,14 @@
* total samples procesed. The only way to take care of that
* is to return here and not fall thru.
*/
- wav->numSamples -= (done / ft->info.channels);
+ wav->numSamples -= (done / ft->signal.channels);
return done;
break;
case ST_ENCODING_GSM:
/* See reason for cooledit check in comments below */
- if (wav->found_cooledit && len > wav->numSamples*ft->info.channels)
- len = (wav->numSamples*ft->info.channels);
+ if (wav->found_cooledit && len > wav->numSamples*ft->signal.channels)
+ len = (wav->numSamples*ft->signal.channels);
done = wavgsmread(ft, buf, len);
if (done == 0 && wav->numSamples != 0)
@@ -1082,8 +1082,8 @@
* greater then 2Gig and can't be represented
* by the 32-bit size field.
*/
- if (wav->found_cooledit && len > wav->numSamples*ft->info.channels)
- len = (wav->numSamples*ft->info.channels);
+ if (wav->found_cooledit && len > wav->numSamples*ft->signal.channels)
+ len = (wav->numSamples*ft->signal.channels);
done = st_rawread(ft, buf, len);
/* If software thinks there are more samples but I/O */
@@ -1095,11 +1095,11 @@
/* Only return buffers that contain a totally playable
* amount of audio.
*/
- done -= done % ft->info.channels;
- if (done/ft->info.channels > wav->numSamples)
+ done -= done % ft->signal.channels;
+ if (done/ft->signal.channels > wav->numSamples)
wav->numSamples = 0;
else
- wav->numSamples -= (done/ft->info.channels);
+ wav->numSamples -= (done/ft->signal.channels);
return done;
}
@@ -1120,7 +1120,7 @@
free(ft->comment);
ft->comment = NULL;
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_GSM:
wavgsmdestroy(ft);
@@ -1142,9 +1142,9 @@
ft->st_errno = ST_SUCCESS;
- if (ft->info.encoding != ST_ENCODING_ADPCM &&
- ft->info.encoding != ST_ENCODING_IMA_ADPCM &&
- ft->info.encoding != ST_ENCODING_GSM)
+ if (ft->signal.encoding != ST_ENCODING_ADPCM &&
+ ft->signal.encoding != ST_ENCODING_IMA_ADPCM &&
+ ft->signal.encoding != ST_ENCODING_GSM)
{
rc = st_rawstartwrite(ft);
if (rc)
@@ -1171,9 +1171,9 @@
/* intentional case fallthru! */
case WAVE_FORMAT_ADPCM:
/* #channels already range-checked for overflow in wavwritehdr() */
- for (ch=0; ch<ft->info.channels; ch++)
+ for (ch=0; ch<ft->signal.channels; ch++)
wav->state[ch] = 0;
- sbsize = ft->info.channels * wav->samplesPerBlock;
+ sbsize = ft->signal.channels * wav->samplesPerBlock;
wav->packet = (unsigned char *)xmalloc(wav->blockAlign);
wav->samples = (short *)xmalloc(sbsize*sizeof(short));
wav->sampleTop = wav->samples + sbsize;
@@ -1279,8 +1279,8 @@
long blocksWritten = 0;
bool isExtensible = false; /* WAVE_FORMAT_EXTENSIBLE? */
- dwSamplesPerSecond = ft->info.rate;
- wChannels = ft->info.channels;
+ dwSamplesPerSecond = ft->signal.rate;
+ wChannels = ft->signal.channels;
/* Check to see if encoding is ADPCM or not. If ADPCM
* possibly override the size to be bytes. It isn't needed
@@ -1287,61 +1287,61 @@
* by this routine will look nicer (and more correct)
* on verbose output.
*/
- if ((ft->info.encoding == ST_ENCODING_ADPCM ||
- ft->info.encoding == ST_ENCODING_IMA_ADPCM ||
- ft->info.encoding == ST_ENCODING_GSM) &&
- ft->info.size != ST_SIZE_BYTE)
+ if ((ft->signal.encoding == ST_ENCODING_ADPCM ||
+ ft->signal.encoding == ST_ENCODING_IMA_ADPCM ||
+ ft->signal.encoding == ST_ENCODING_GSM) &&
+ ft->signal.size != ST_SIZE_BYTE)
{
st_report("Overriding output size to bytes for compressed data.");
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.size = ST_SIZE_BYTE;
}
- switch (ft->info.size)
+ switch (ft->signal.size)
{
case ST_SIZE_BYTE:
wBitsPerSample = 8;
- if (ft->info.encoding != ST_ENCODING_UNSIGNED &&
- ft->info.encoding != ST_ENCODING_ULAW &&
- ft->info.encoding != ST_ENCODING_ALAW &&
- ft->info.encoding != ST_ENCODING_GSM &&
- ft->info.encoding != ST_ENCODING_ADPCM &&
- ft->info.encoding != ST_ENCODING_IMA_ADPCM)
+ if (ft->signal.encoding != ST_ENCODING_UNSIGNED &&
+ ft->signal.encoding != ST_ENCODING_ULAW &&
+ ft->signal.encoding != ST_ENCODING_ALAW &&
+ ft->signal.encoding != ST_ENCODING_GSM &&
+ ft->signal.encoding != ST_ENCODING_ADPCM &&
+ ft->signal.encoding != ST_ENCODING_IMA_ADPCM)
{
- st_report("Do not support %s with 8-bit data. Forcing to unsigned",st_encodings_str[(unsigned char)ft->info.encoding]);
- ft->info.encoding = ST_ENCODING_UNSIGNED;
+ st_report("Do not support %s with 8-bit data. Forcing to unsigned",st_encodings_str[(unsigned char)ft->signal.encoding]);
+ ft->signal.encoding = ST_ENCODING_UNSIGNED;
}
break;
case ST_SIZE_WORD:
wBitsPerSample = 16;
- if (ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->signal.encoding != ST_ENCODING_SIGN2)
{
- st_report("Do not support %s with 16-bit data. Forcing to Signed.",st_encodings_str[(unsigned char)ft->info.encoding]);
- ft->info.encoding = ST_ENCODING_SIGN2;
+ st_report("Do not support %s with 16-bit data. Forcing to Signed.",st_encodings_str[(unsigned char)ft->signal.encoding]);
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
break;
case ST_SIZE_24BIT:
wBitsPerSample = 24;
- if (ft->info.encoding != ST_ENCODING_SIGN2)
+ if (ft->signal.encoding != ST_ENCODING_SIGN2)
{
- st_report("Do not support %s with 24-bit data. Forcing to Signed.",st_encodings_str[(unsigned char)ft->info.encoding]);
- ft->info.encoding = ST_ENCODING_SIGN2;
+ st_report("Do not support %s with 24-bit data. Forcing to Signed.",st_encodings_str[(unsigned char)ft->signal.encoding]);
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
break;
case ST_SIZE_DWORD:
wBitsPerSample = 32;
- if (ft->info.encoding != ST_ENCODING_SIGN2 &&
- ft->info.encoding != ST_ENCODING_FLOAT)
+ if (ft->signal.encoding != ST_ENCODING_SIGN2 &&
+ ft->signal.encoding != ST_ENCODING_FLOAT)
{
- st_report("Do not support %s with 32-bit data. Forcing to Signed.",st_encodings_str[(unsigned char)ft->info.encoding]);
- ft->info.encoding = ST_ENCODING_SIGN2;
+ st_report("Do not support %s with 32-bit data. Forcing to Signed.",st_encodings_str[(unsigned char)ft->signal.encoding]);
+ ft->signal.encoding = ST_ENCODING_SIGN2;
}
break;
default:
- st_report("Do not support %s in WAV files. Forcing to Signed Words.",st_sizes_str[(unsigned char)ft->info.size]);
- ft->info.encoding = ST_ENCODING_SIGN2;
- ft->info.size = ST_SIZE_WORD;
+ st_report("Do not support %s in WAV files. Forcing to Signed Words.",st_sizes_str[(unsigned char)ft->signal.size]);
+ ft->signal.encoding = ST_ENCODING_SIGN2;
+ ft->signal.size = ST_SIZE_WORD;
wBitsPerSample = 16;
break;
}
@@ -1348,7 +1348,7 @@
wSamplesPerBlock = 1; /* common default for PCM data */
- switch (ft->info.encoding)
+ switch (ft->signal.encoding)
{
case ST_ENCODING_UNSIGNED:
case ST_ENCODING_SIGN2:
@@ -1397,7 +1397,7 @@
if (wChannels!=1)
{
st_report("Overriding GSM audio from %d channel to 1",wChannels);
- wChannels = ft->info.channels = 1;
+ wChannels = ft->signal.channels = 1;
}
wFormatTag = WAVE_FORMAT_GSM610;
/* dwAvgBytesPerSec = 1625*(dwSamplesPerSecond/8000.)+0.5; */
@@ -1449,7 +1449,7 @@
wRiffLength += (8+dwFactSize);
/* dwAvgBytesPerSec <-- this is BEFORE compression, isn't it? guess not. */
- dwAvgBytesPerSec = (double)wBlockAlign*ft->info.rate / (double)wSamplesPerBlock + 0.5;
+ dwAvgBytesPerSec = (double)wBlockAlign*ft->signal.rate / (double)wSamplesPerBlock + 0.5;
/* figured out header info, so write it */
@@ -1457,7 +1457,7 @@
/* If user specified opposite swap then we think, assume they are
* asking to write a RIFX file.
*/
- if (ft->info.swap_bytes != ST_IS_BIGENDIAN)
+ if (ft->signal.swap_bytes != ST_IS_BIGENDIAN)
{
if (!second_header)
st_report("Requested to swap bytes so writing RIFX header");
@@ -1576,13 +1576,13 @@
case WAVE_FORMAT_GSM610:
len = wavgsmwrite(ft, buf, len);
- wav->numSamples += (len/ft->info.channels);
+ wav->numSamples += (len/ft->signal.channels);
return len;
break;
default:
len = st_rawwrite(ft, buf, len);
- wav->numSamples += (len/ft->info.channels);
+ wav->numSamples += (len/ft->signal.channels);
return len;
}
}
@@ -1695,9 +1695,9 @@
st_fail_errno(ft,ST_ENOTSUP,"Only PCM Supported");
break;
default:
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -1710,8 +1710,8 @@
ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
if( ft->st_errno == ST_SUCCESS )
- wav->numSamples = (ft->length / ft->info.channels) -
- (new_offset / ft->info.size / ft->info.channels);
+ wav->numSamples = (ft->length / ft->signal.channels) -
+ (new_offset / ft->signal.size / ft->signal.channels);
}
return(ft->st_errno);
--- a/src/wve.c
+++ b/src/wve.c
@@ -30,9 +30,9 @@
int new_offset, channel_block, alignment;
wve_t wve = (wve_t ) ft->priv;
- new_offset = offset * ft->info.size;
+ new_offset = offset * ft->signal.size;
/* Make sure request aligns to a channel block (ie left+right) */
- channel_block = ft->info.channels * ft->info.size;
+ channel_block = ft->signal.channels * ft->signal.size;
alignment = new_offset % channel_block;
/* Most common mistaken is to compute something like
* "skip everthing upto and including this sample" so
@@ -79,7 +79,7 @@
* testing for endianess was standardized. Leaving since
* it doesn't hurt.
*/
- ft->info.swap_bytes = !ft->info.swap_bytes;
+ ft->signal.swap_bytes = !ft->signal.swap_bytes;
st_debug("Found inverted PSION magic word. Swapping bytes.");
}
else if (version == PSION_VERSION)
@@ -102,19 +102,19 @@
(void)st_readw(ft, (unsigned short *)&trash16);
(void)st_readw(ft, (unsigned short *)&trash16);
- ft->info.encoding = ST_ENCODING_ALAW;
- ft->info.size = ST_SIZE_BYTE;
+ ft->signal.encoding = ST_ENCODING_ALAW;
+ ft->signal.size = ST_SIZE_BYTE;
- if (ft->info.rate != 0)
+ if (ft->signal.rate != 0)
st_report("WVE must use 8000 sample rate. Overriding");
- ft->info.rate = 8000;
+ ft->signal.rate = 8000;
- if (ft->info.channels != ST_ENCODING_UNKNOWN && ft->info.channels != 1)
+ if (ft->signal.channels != ST_ENCODING_UNKNOWN && ft->signal.channels != 1)
st_report("WVE must only supports 1 channel. Overriding");
- ft->info.channels = 1;
+ ft->signal.channels = 1;
p->dataStart = st_tell(ft);
- ft->length = p->length/ft->info.size;
+ ft->length = p->length/ft->signal.size;
return (ST_SUCCESS);
}
@@ -142,15 +142,15 @@
if (p->repeats == 0)
p->repeats = 1;
- if (ft->info.rate != 0)
+ if (ft->signal.rate != 0)
st_report("WVE must use 8000 sample rate. Overriding");
- if (ft->info.channels != 0 && ft->info.channels != 1)
+ if (ft->signal.channels != 0 && ft->signal.channels != 1)
st_report("WVE must only supports 1 channel. Overriding");
- ft->info.encoding = ST_ENCODING_ALAW;
- ft->info.size = ST_SIZE_BYTE;
- ft->info.rate = 8000;
+ ft->signal.encoding = ST_ENCODING_ALAW;
+ ft->signal.size = ST_SIZE_BYTE;
+ ft->signal.rate = 8000;
wvewriteheader(ft);
return ST_SUCCESS;
@@ -159,7 +159,7 @@
static st_size_t st_wvewrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
{
wve_t p = (wve_t ) ft->priv;
- p->length += samp * ft->info.size;
+ p->length += samp * ft->signal.size;
return st_rawwrite(ft, buf, samp);
}
--- a/src/xa.c
+++ b/src/xa.c
@@ -130,43 +130,43 @@
st_debug(" wBits: %u", xa->header.bits);
/* Populate the st_soundstream structure */
- ft->info.encoding = ST_ENCODING_SIGN2;
+ ft->signal.encoding = ST_ENCODING_SIGN2;
- if (ft->info.size == -1 || ft->info.size == (xa->header.bits >> 3)) {
- ft->info.size = xa->header.bits >> 3;
+ if (ft->signal.size == -1 || ft->signal.size == (xa->header.bits >> 3)) {
+ ft->signal.size = xa->header.bits >> 3;
} else {
st_report("User options overriding size read in .xa header");
}
- if (ft->info.channels == 0 || ft->info.channels == xa->header.channels) {
- ft->info.channels = xa->header.channels;
+ if (ft->signal.channels == 0 || ft->signal.channels == xa->header.channels) {
+ ft->signal.channels = xa->header.channels;
} else {
st_report("User options overriding channels read in .xa header");
}
- if (ft->info.rate == 0 || ft->info.rate == xa->header.sampleRate) {
- ft->info.rate = xa->header.sampleRate;
+ if (ft->signal.rate == 0 || ft->signal.rate == xa->header.sampleRate) {
+ ft->signal.rate = xa->header.sampleRate;
} else {
st_report("User options overriding rate read in .xa header");
}
/* Check for supported formats */
- if (ft->info.size != 2) {
+ if (ft->signal.size != 2) {
st_fail_errno(ft, ST_EFMT, "%d-bit sample resolution not supported.",
- ft->info.size << 3);
+ ft->signal.size << 3);
return ST_EOF;
}
/* Validate the header */
- if (xa->header.bits != ft->info.size << 3) {
+ if (xa->header.bits != ft->signal.size << 3) {
st_report("Invalid sample resolution %d bits. Assuming %d bits.",
- xa->header.bits, ft->info.size << 3);
- xa->header.bits = ft->info.size << 3;
+ xa->header.bits, ft->signal.size << 3);
+ xa->header.bits = ft->signal.size << 3;
}
- if (xa->header.align != ft->info.size * xa->header.channels) {
+ if (xa->header.align != ft->signal.size * xa->header.channels) {
st_report("Invalid sample alignment value %d. Assuming %d.",
- xa->header.align, ft->info.size * xa->header.channels);
- xa->header.align = ft->info.size * xa->header.channels;
+ xa->header.align, ft->signal.size * xa->header.channels);
+ xa->header.align = ft->signal.size * xa->header.channels;
}
if (xa->header.avgByteRate != (xa->header.align * xa->header.sampleRate)) {
st_report("Invalid dwAvgByteRate value %d. Assuming %d.",
@@ -175,7 +175,7 @@
}
/* Set up the block buffer */
- xa->blockSize = ft->info.channels * 0xf;
+ xa->blockSize = ft->signal.channels * 0xf;
xa->bufPos = xa->blockSize;
/* Allocate memory for the block buffer */
@@ -182,7 +182,7 @@
xa->buf = (unsigned char *)xcalloc(1, xa->blockSize);
/* Allocate memory for the state */
- xa->state = (xa_state_t *)xcalloc(sizeof(xa_state_t), ft->info.channels);
+ xa->state = (xa_state_t *)xcalloc(sizeof(xa_state_t), ft->signal.channels);
/* Final initialization */
xa->bytesDecoded = 0;
@@ -222,16 +222,16 @@
}
xa->bufPos = 0;
- for (i = 0; i < ft->info.channels; i++) {
+ for (i = 0; i < ft->signal.channels; i++) {
inByte = xa->buf[i];
xa->state[i].c1 = EA_ADPCM_Table[HNIBBLE(inByte)];
xa->state[i].c2 = EA_ADPCM_Table[HNIBBLE(inByte) + 4];
xa->state[i].shift = LNIBBLE(inByte) + 8;
}
- xa->bufPos += ft->info.channels;
+ xa->bufPos += ft->signal.channels;
} else {
/* Process the block */
- for (i = 0; i < ft->info.channels && done < len; i++) {
+ for (i = 0; i < ft->signal.channels && done < len; i++) {
/* high nibble */
sample = HNIBBLE(xa->buf[xa->bufPos+i]);
sample = (sample << 28) >> xa->state[i].shift;
@@ -243,9 +243,9 @@
xa->state[i].curSample = sample;
buf[done++] = ST_SIGNED_WORD_TO_SAMPLE(sample,);
- xa->bytesDecoded += ft->info.size;
+ xa->bytesDecoded += ft->signal.size;
}
- for (i = 0; i < ft->info.channels && done < len; i++) {
+ for (i = 0; i < ft->signal.channels && done < len; i++) {
/* low nibble */
sample = LNIBBLE(xa->buf[xa->bufPos+i]);
sample = (sample << 28) >> xa->state[i].shift;
@@ -257,10 +257,10 @@
xa->state[i].curSample = sample;
buf[done++] = ST_SIGNED_WORD_TO_SAMPLE(sample,);
- xa->bytesDecoded += ft->info.size;
+ xa->bytesDecoded += ft->signal.size;
}
- xa->bufPos += ft->info.channels;
+ xa->bufPos += ft->signal.channels;
}
}
if (done == 0) {