ref: b7c61db0a37cbc49d9195233143c640aad1b01d9
parent: 34d83c1c8e6dfa635a57c3cd07b54c222b6f39f7
author: cbagwell <cbagwell>
date: Tue Oct 30 20:36:58 EST 2001
Moving to better 64-bit support.
--- a/Changelog
+++ b/Changelog
@@ -26,6 +26,13 @@
problem.
o Erik de Castro Lopo pointed out that when writing 16-bit VOC files
the headers did not contain the correct length or encoding type.
+ o Seperated st.h into 2 files. st.h for libst users and st_i.h for
+ internal use.
+ o SoX was some times getting confused and thinking an EOF was an
+ error case when reading audio files. Removed unneeded aborts
+ when EOF was OK.
+ o Change libst to use two new data types: st_sample_t and st_size_t.
+ This allows for better support and maintaince on 64-bit machines.
sox-12.17.2
-----------
--- a/libst.c
+++ b/libst.c
@@ -1,7 +1,7 @@
/* libst.c - portable sound tools library
*/
-#include "st.h"
+#include "st_i.h"
#include "libst.h"
#ifndef FAST_ULAW_CONVERSION
--- a/nul.c
+++ b/nul.c
@@ -16,7 +16,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for nul file */
typedef struct nulstuff {
@@ -32,8 +32,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_nulstartread(ft)
-ft_t ft;
+int st_nulstartread(ft_t ft)
{
nul_t sk = (nul_t) ft->priv;
/* no samples read yet */
@@ -66,9 +65,7 @@
* Return number of samples read.
*/
-LONG st_nulread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_nulread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
nul_t sk = (nul_t) ft->priv;
int done = 0;
@@ -88,14 +85,12 @@
* Don't close input file!
* .. nothing to be done
*/
-int st_nulstopread(ft)
-ft_t ft;
+int st_nulstopread(ft_t ft)
{
return (ST_SUCCESS);
}
-int st_nulstartwrite(ft)
-ft_t ft;
+int st_nulstartwrite(ft_t ft)
{
nul_t sk = (nul_t) ft->priv;
sk->writesamples=0;
@@ -103,9 +98,7 @@
}
-LONG st_nulwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_nulwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
nul_t sk = (nul_t) ft->priv;
while(len--)
@@ -115,8 +108,7 @@
}
-int st_nulstopwrite(ft)
-ft_t ft;
+int st_nulstopwrite(ft_t ft)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/pick.c
+++ b/pick.c
@@ -1,4 +1,3 @@
-
/*
* July 5, 1991
* Copyright 1991 Lance Norskog And Sundry Contributors
@@ -15,7 +14,7 @@
* file by selecting 2 channels from a 4 channel file.
*/
-#include "st.h"
+#include "st_i.h"
/* Private data for SKEL file */
typedef struct pickstuff {
@@ -31,10 +30,7 @@
/*
* Process options
*/
-int st_pick_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_pick_getopts(eff_t effp, int n, char **argv)
{
pick_t pick = (pick_t) effp->priv;
@@ -74,8 +70,7 @@
* channels selected, and that info is not available in pick_getopts()
* above.
*/
-int st_pick_start(effp)
-eff_t effp;
+int st_pick_start(eff_t effp)
{
pick_t pick = (pick_t) effp->priv;
@@ -110,11 +105,8 @@
* isamp or osamp samples, whichever is smaller,
* while picking appropriate channels.
*/
-
-int st_pick_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_pick_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
pick_t pick = (pick_t) effp->priv;
int len, done;
@@ -146,8 +138,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_pick_stop(effp)
-eff_t effp;
+int st_pick_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/split.c
+++ b/split.c
@@ -15,7 +15,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for split */
typedef struct splitstuff {
@@ -25,10 +25,7 @@
/*
* Process options
*/
-int st_split_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_split_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -41,8 +38,7 @@
/*
* Prepare processing.
*/
-int st_split_start(effp)
-eff_t effp;
+int st_split_start(eff_t effp)
{
switch (effp->ininfo.channels) {
case 1: /* 1 channel must split to 2 or 4 */
@@ -69,11 +65,8 @@
* isamp or osamp samples, whichever is smaller,
* while splitting into appropriate channels.
*/
-
-int st_split_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_split_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
int len, done;
@@ -125,8 +118,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_split_stop(effp)
-eff_t effp;
+int st_split_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -12,22 +12,21 @@
#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
-#include "st.h"
+#include "st_i.h"
/* Private data used by writer */
typedef struct svxpriv {
- ULONG nsamples;
+ st_size_t nsamples;
FILE *ch[4];
}*svx_t;
-static void svxwriteheader(ft_t, LONG);
+static void svxwriteheader(ft_t, st_ssize_t);
/*======================================================================*/
/* 8SVXSTARTREAD */
/*======================================================================*/
-int st_svxstartread(ft)
-ft_t ft;
+int st_svxstartread(ft_t ft)
{
svx_t p = (svx_t ) ft->priv;
@@ -34,14 +33,14 @@
char buf[12];
char *chunk_buf;
- ULONG totalsize;
- ULONG chunksize;
+ st_size_t totalsize;
+ st_size_t chunksize;
ULONG channels;
unsigned short rate;
int i;
- ULONG chan1_pos;
+ long chan1_pos;
if (! ft->seekable)
{
@@ -188,7 +187,7 @@
chan1_pos = ftell(p->ch[0]);
for (i = 1; i < channels; i++) {
- if ((p->ch[i] = fopen(ft->filename, READBINARY)) == NULL)
+ if ((p->ch[i] = fopen(ft->filename, "rb")) == NULL)
{
st_fail_errno(ft,errno,"Can't open channel file '%s'",
ft->filename);
@@ -213,9 +212,7 @@
/*======================================================================*/
/* 8SVXREAD */
/*======================================================================*/
-LONG st_svxread(ft, buf, nsamp)
-ft_t ft;
-LONG *buf, nsamp;
+st_ssize_t st_svxread(ft_t ft, st_sample_t *buf, st_ssize_t nsamp)
{
unsigned char datum;
int done = 0;
@@ -240,8 +237,7 @@
/*======================================================================*/
/* 8SVXSTOPREAD */
/*======================================================================*/
-int st_svxstopread(ft)
-ft_t ft;
+int st_svxstopread(ft_t ft)
{
int i;
@@ -257,8 +253,7 @@
/*======================================================================*/
/* 8SVXSTARTWRITE */
/*======================================================================*/
-int st_svxstartwrite(ft)
-ft_t ft;
+int st_svxstartwrite(ft_t ft)
{
svx_t p = (svx_t ) ft->priv;
int i;
@@ -294,9 +289,7 @@
/* 8SVXWRITE */
/*======================================================================*/
-LONG st_svxwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_svxwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
svx_t p = (svx_t ) ft->priv;
@@ -321,8 +314,7 @@
/* 8SVXSTOPWRITE */
/*======================================================================*/
-int st_svxstopwrite(ft)
-ft_t ft;
+int st_svxstopwrite(ft_t ft)
{
svx_t p = (svx_t ) ft->priv;
@@ -363,9 +355,7 @@
/* 8SVXWRITEHEADER */
/*======================================================================*/
#define SVXHEADERSIZE 100
-static void svxwriteheader(ft,nsamples)
-ft_t ft;
-LONG nsamples;
+static void svxwriteheader(ft_t ft, st_ssize_t nsamples)
{
LONG formsize = nsamples + SVXHEADERSIZE - 8;
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -51,7 +51,7 @@
#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
-#include "st.h"
+#include "st_i.h"
/* Private data used by writer */
typedef struct aiffpriv {
@@ -70,9 +70,7 @@
static int commentChunk(char **text, char *chunkDescription, ft_t ft);
static void reportInstrument(ft_t ft);
-int st_aiffseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_aiffseek(ft_t ft,st_size_t offset)
{
aiff_t aiff = (aiff_t ) ft->priv;
@@ -84,8 +82,7 @@
return(ft->st_errno);
}
-int st_aiffstartread(ft)
-ft_t ft;
+int st_aiffstartread(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
char buf[5];
@@ -463,8 +460,7 @@
}
/* print out the MIDI key allocations, loop points, directions etc */
-static void reportInstrument(ft)
-ft_t ft;
+static void reportInstrument(ft_t ft)
{
int loopNum;
@@ -490,10 +486,7 @@
}
/* Process a text chunk, allocate memory, display it if verbose and return */
-static int textChunk(text, chunkDescription, ft)
-char **text;
-char *chunkDescription;
-ft_t ft;
+static int textChunk(char **text, char *chunkDescription, ft_t ft)
{
LONG chunksize;
st_readdw(ft, &chunksize);
@@ -527,10 +520,7 @@
/* Comment lengths are words, not double words, and we can have several, so
we use a special function, not textChunk().;
*/
-static int commentChunk(text, chunkDescription, ft)
-char **text;
-char *chunkDescription;
-ft_t ft;
+static int commentChunk(char **text, char *chunkDescription, ft_t ft)
{
LONG chunksize;
unsigned short numComments;
@@ -578,9 +568,7 @@
return(ST_SUCCESS);
}
-LONG st_aiffread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_aiffread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
aiff_t aiff = (aiff_t ) ft->priv;
LONG done;
@@ -595,8 +583,7 @@
return done;
}
-int st_aiffstopread(ft)
-ft_t ft;
+int st_aiffstopread(ft_t ft)
{
char buf[5];
ULONG chunksize;
@@ -639,8 +626,7 @@
Strictly spoken this is not legal, but the playaiff utility
will still be able to play the resulting file. */
-int st_aiffstartwrite(ft)
-ft_t ft;
+int st_aiffstartwrite(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
int rc;
@@ -675,9 +661,7 @@
return(aiffwriteheader(ft, 0x7f000000L / (ft->info.size*ft->info.channels)));
}
-LONG st_aiffwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_aiffwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
aiff_t aiff = (aiff_t ) ft->priv;
aiff->nsamples += len;
@@ -685,8 +669,7 @@
return(len);
}
-int st_aiffstopwrite(ft)
-ft_t ft;
+int st_aiffstopwrite(ft_t ft)
{
aiff_t aiff = (aiff_t ) ft->priv;
int rc;
@@ -711,9 +694,7 @@
return(aiffwriteheader(ft, aiff->nsamples / ft->info.channels));
}
-static int aiffwriteheader(ft, nframes)
-ft_t ft;
-LONG nframes;
+static int aiffwriteheader(ft_t ft, LONG nframes)
{
int hsize =
8 /*COMM hdr*/ + 18 /*COMM chunk*/ +
@@ -849,8 +830,7 @@
return(ST_SUCCESS);
}
-static double read_ieee_extended(ft)
-ft_t ft;
+static double read_ieee_extended(ft_t ft)
{
char buf[10];
if (fread(buf, 1, 10, ft->fp) != 10)
@@ -861,9 +841,7 @@
return ConvertFromIeeeExtended(buf);
}
-static void write_ieee_extended(ft, x)
-ft_t ft;
-double x;
+static void write_ieee_extended(ft_t ft, double x)
{
char buf[10];
ConvertToIeeeExtended(x, buf);
@@ -918,9 +896,7 @@
# define FloatToUnsigned(f) ((ULONG)(((LONG)(f - 2147483648.0)) + 2147483647L) + 1)
-static void ConvertToIeeeExtended(num, bytes)
-double num;
-char *bytes;
+static void ConvertToIeeeExtended(double num, char *bytes)
{
int sign;
int expon;
@@ -1017,8 +993,7 @@
* Extended precision IEEE floating-point conversion routine.
****************************************************************/
-static double ConvertFromIeeeExtended(bytes)
-unsigned char *bytes; /* LCN */
+static double ConvertFromIeeeExtended(unsigned char *bytes)
{
double f;
int expon;
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -17,7 +17,7 @@
#include <fcntl.h>
#include <linux/asound.h>
#include <sys/ioctl.h>
-#include "st.h"
+#include "st_i.h"
static int get_format(ft_t ft, int formats, int *fmt);
--- a/src/au.c
+++ b/src/au.c
@@ -19,7 +19,7 @@
* Output is always in big-endian (Sun/NeXT) order.
*/
-#include "st.h"
+#include "st_i.h"
#include "g72x.h"
#include <stdlib.h>
#include <string.h>
@@ -61,10 +61,7 @@
static void auwriteheader(ft_t ft, ULONG data_size);
-int st_auencodingandsize(sun_encoding, encoding, size)
-int sun_encoding;
-int *encoding;
-int *size;
+static int st_auencodingandsize(int sun_encoding, char *encoding, char *size)
{
switch (sun_encoding) {
case SUN_ULAW:
@@ -102,9 +99,7 @@
return(ST_SUCCESS);
}
-int st_auseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_auseek(ft_t ft, st_size_t offset)
{
au_t au = (au_t ) ft->priv;
@@ -116,8 +111,7 @@
return(ft->st_errno);
}
-int st_austartread(ft)
-ft_t ft;
+int st_austartread(ft_t ft)
{
/* The following 6 variables represent a Sun sound header on disk.
The numbers are written as big-endians.
@@ -269,8 +263,7 @@
if it is not, the unspecified size remains in the header
(this is legal). */
-int st_austartwrite(ft)
-ft_t ft;
+int st_austartwrite(ft_t ft)
{
au_t p = (au_t ) ft->priv;
int rc;
@@ -298,10 +291,7 @@
* Returns 1 if there is residual input, returns -1 if eof, else returns 0.
* (Adapted from Sun's decode.c.)
*/
-static int
-unpack_input(ft, code)
-ft_t ft;
-unsigned char *code;
+static int unpack_input(ft_t ft, unsigned char *code)
{
au_t p = (au_t ) ft->priv;
unsigned char in_byte;
@@ -320,9 +310,7 @@
return (p->in_bits > 0);
}
-LONG st_auread(ft, buf, samp)
-ft_t ft;
-LONG *buf, samp;
+st_ssize_t st_auread(ft_t ft, st_sample_t *buf, st_ssize_t samp)
{
au_t p = (au_t ) ft->priv;
unsigned char code;
@@ -340,9 +328,7 @@
return done;
}
-LONG st_auwrite(ft, buf, samp)
-ft_t ft;
-LONG *buf, samp;
+st_ssize_t st_auwrite(ft_t ft, st_sample_t *buf, st_ssize_t samp)
{
au_t p = (au_t ) ft->priv;
p->data_size += samp * ft->info.size;
@@ -349,8 +335,7 @@
return(st_rawwrite(ft, buf, samp));
}
-int st_austopwrite(ft)
-ft_t ft;
+int st_austopwrite(ft_t ft)
{
au_t p = (au_t ) ft->priv;
int rc;
@@ -375,9 +360,7 @@
return(ST_SUCCESS);
}
-int st_ausunencoding(size, encoding)
-int size;
-int encoding;
+static int st_ausunencoding(int size, int encoding)
{
int sun_encoding;
@@ -394,9 +377,7 @@
return sun_encoding;
}
-static void auwriteheader(ft, data_size)
-ft_t ft;
-ULONG data_size;
+static void auwriteheader(ft_t ft, st_size_t data_size)
{
ULONG magic;
ULONG hdr_size;
--- a/src/auto.c
+++ b/src/auto.c
@@ -14,7 +14,7 @@
* used any more -- but this is just laziness on my part.)
*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
#if defined(DOS) || defined(WIN32)
@@ -23,8 +23,7 @@
#define LASTCHAR '/'
#endif
-int st_autostartread(ft)
-ft_t ft;
+int st_autostartread(ft_t ft)
{
char *type;
char header[20];
@@ -86,9 +85,9 @@
if (fread(header, 1, 1, ft->fp) == 1 && *header == 'D')
{
/* Once we've found SOUND see if its smp or sndt */
- if (fread(header, 1, 13, ft->fp) == 13)
+ if (fread(header, 1, 12, ft->fp) == 12)
{
- if (strncmp(header, "D SAMPLE DATA", 13) == 0)
+ if (strncmp(header, " SAMPLE DATA", 12) == 0)
type = "smp";
else
type = "sndt";
@@ -167,8 +166,7 @@
return ((* ft->h->startread)(ft));
}
-int st_autostartwrite(ft)
-ft_t ft;
+int st_autostartwrite(ft_t ft)
{
st_fail_errno(ft,ST_EFMT,"Type AUTO can only be used for input!");
return(ST_EOF);
--- a/src/avg.c
+++ b/src/avg.c
@@ -18,9 +18,10 @@
* What's in a center channel?
*/
-#include "st.h"
+#include "st_i.h"
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>
/* Private data for SKEL file */
typedef struct avgstuff {
@@ -41,311 +42,304 @@
#define MIX_BACK 4
#define MIX_SPECIFIED 5
-extern double atof();
-
#define CLIP_LEVEL ((double)(((unsigned)1 << 31) - 1))
/*
* Process options
*/
-int st_avg_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_avg_getopts(eff_t effp, int n, char **argv)
{
- avg_t avg = (avg_t) effp->priv;
- double* pans = &avg->sources[0][0];
- int i;
+ avg_t avg = (avg_t) effp->priv;
+ double* pans = &avg->sources[0][0];
+ int i;
- for (i = 0; i < 16; i++)
- pans[i] = 0.0;
- avg->mix = MIX_CENTER;
- avg->num_pans = 0;
+ for (i = 0; i < 16; i++)
+ pans[i] = 0.0;
+ avg->mix = MIX_CENTER;
+ avg->num_pans = 0;
- /* Parse parameters. Since we don't yet know the number of */
- /* input and output channels, we'll record the information for */
- /* later. */
- if (n) {
- if(!strcmp(argv[0], "-l"))
- avg->mix = MIX_LEFT;
- else if (!strcmp(argv[0], "-r"))
- avg->mix = MIX_RIGHT;
- else if (!strcmp(argv[0], "-f"))
- avg->mix = MIX_FRONT;
- else if (!strcmp(argv[0], "-b"))
- avg->mix = MIX_BACK;
- else if (argv[0][0] == '-' && !isdigit((int)argv[0][1])
- && argv[0][1] != '.') {
- st_fail("Usage: avg [ -l | -r | -f | -b | n,n,n...,n ]");
+ /* Parse parameters. Since we don't yet know the number of */
+ /* input and output channels, we'll record the information for */
+ /* later. */
+ if (n) {
+ if(!strcmp(argv[0], "-l"))
+ avg->mix = MIX_LEFT;
+ else if (!strcmp(argv[0], "-r"))
+ avg->mix = MIX_RIGHT;
+ else if (!strcmp(argv[0], "-f"))
+ avg->mix = MIX_FRONT;
+ else if (!strcmp(argv[0], "-b"))
+ avg->mix = MIX_BACK;
+ else if (argv[0][0] == '-' && !isdigit((int)argv[0][1])
+ && argv[0][1] != '.') {
+ st_fail("Usage: avg [ -l | -r | -f | -b | n,n,n...,n ]");
+ return (ST_EOF);
+ }
+ else {
+ int commas;
+ char *s;
+ avg->mix = MIX_SPECIFIED;
+ pans[0] = atof(argv[0]);
+ for (s = argv[0], commas = 0; *s; ++s) {
+ if (*s == ',') {
+ ++commas;
+ if (commas >= 16) {
+ st_fail("avg can only take up to 16 pan values");
return (ST_EOF);
+ }
+ pans[commas] = atof(s+1);
}
- else {
- int commas;
- char *s;
- avg->mix = MIX_SPECIFIED;
- pans[0] = atof(argv[0]);
- for (s = argv[0], commas = 0; *s; ++s) {
- if (*s == ',') {
- ++commas;
- if (commas >= 16) {
- st_fail("avg can only take up to 16 pan values");
- return (ST_EOF);
- }
- pans[commas] = atof(s+1);
- }
- }
- avg->num_pans = commas + 1;
- }
+ }
+ avg->num_pans = commas + 1;
}
- else {
- pans[0] = 0.5;
- pans[1] = 0.5;
- avg->num_pans = 2;
- }
- return (ST_SUCCESS);
+ }
+ else {
+ pans[0] = 0.5;
+ pans[1] = 0.5;
+ avg->num_pans = 2;
+ }
+ return (ST_SUCCESS);
}
/*
* Start processing
*/
-
-int st_avg_start(effp)
-eff_t effp;
+int st_avg_start(eff_t effp)
{
- /*
- Hmmm, this is tricky. Lemme think:
- channel orders are [0][0],[0][1], etc.
- i.e., 0->0, 0->1, 0->2, 0->3, 1->0, 1->1, ...
- trailing zeros are omitted
- L/R balance is x= -1 for left only, 1 for right only
- 1->1 channel effects:
- changing volume by x is x,0,0,0
- 1->2 channel effects:
- duplicating everywhere is 1,1,0,0
- 1->4 channel effects:
- duplicating everywhere is 1,1,1,1
- 2->1 channel effects:
- left only is 1,0,0,0 0,0,0,0
- right only is 0,0,0,0 1,0,0,0
- left+right is 0.5,0,0,0 0.5,0,0,0
- left-right is 1,0,0,0 -1,0,0,0
- 2->2 channel effects:
- L/R balance can be done several ways. The standard stereo
- way is both the easiest and the most sensible:
- min(1-x,1),0,0,0 0,min(1+x,1),0,0
- left to both is 1,1,0,0
- right to both is 0,0,0,0 1,1,0,0
- left+right to both is 0.5,0.5,0,0 0.5,0.5,0,0
- left-right to both is 1,1,0,0 -1,-1,0,0
- left-right to left, right-left to right is 1,-1,0,0 -1,1,0,0
- 2->4 channel effects:
- front duplicated into rear is 1,0,1,0 0,1,0,1
- front swapped into rear (why?) is 1,0,0,1 0,1,1,0
- front put into rear as mono (why?) is 1,0,0.5,0.5 0,1,0.5,0.5
- 4->1 channel effects:
- left front only is 1,0,0,0
- left only is 0.5,0,0,0 0,0,0,0 0.5,0,0,0
- etc.
- 4->2 channel effects:
- merge front/back is 0.5,0,0,0 0,0.5,0,0 0.5,0,0,0 0,0.5,0,0
- selections similar to above
- 4->4 channel effects:
- left front to all is 1,1,1,1 0,0,0,0
- right front to all is 0,0,0,0 1,1,1,1
- left f/r to all f/r is 1,1,0,0 0,0,0,0 0,0,1,1 0,0,0,0
- etc.
+ /*
+ Hmmm, this is tricky. Lemme think:
+ channel orders are [0][0],[0][1], etc.
+ i.e., 0->0, 0->1, 0->2, 0->3, 1->0, 1->1, ...
+ trailing zeros are omitted
+ L/R balance is x= -1 for left only, 1 for right only
+ 1->1 channel effects:
+ changing volume by x is x,0,0,0
+ 1->2 channel effects:
+ duplicating everywhere is 1,1,0,0
+ 1->4 channel effects:
+ duplicating everywhere is 1,1,1,1
+ 2->1 channel effects:
+ left only is 1,0,0,0 0,0,0,0
+ right only is 0,0,0,0 1,0,0,0
+ left+right is 0.5,0,0,0 0.5,0,0,0
+ left-right is 1,0,0,0 -1,0,0,0
+ 2->2 channel effects:
+ L/R balance can be done several ways. The standard stereo
+ way is both the easiest and the most sensible:
+ min(1-x,1),0,0,0 0,min(1+x,1),0,0
+ left to both is 1,1,0,0
+ right to both is 0,0,0,0 1,1,0,0
+ left+right to both is 0.5,0.5,0,0 0.5,0.5,0,0
+ left-right to both is 1,1,0,0 -1,-1,0,0
+ left-right to left, right-left to right is 1,-1,0,0 -1,1,0,0
+ 2->4 channel effects:
+ front duplicated into rear is 1,0,1,0 0,1,0,1
+ front swapped into rear (why?) is 1,0,0,1 0,1,1,0
+ front put into rear as mono (why?) is 1,0,0.5,0.5 0,1,0.5,0.5
+ 4->1 channel effects:
+ left front only is 1,0,0,0
+ left only is 0.5,0,0,0 0,0,0,0 0.5,0,0,0
+ etc.
+ 4->2 channel effects:
+ merge front/back is 0.5,0,0,0 0,0.5,0,0 0.5,0,0,0 0,0.5,0,0
+ selections similar to above
+ 4->4 channel effects:
+ left front to all is 1,1,1,1 0,0,0,0
+ right front to all is 0,0,0,0 1,1,1,1
+ left f/r to all f/r is 1,1,0,0 0,0,0,0 0,0,1,1 0,0,0,0
+ etc.
- The interesting ones from above (deserving of abbreviations of
- less than 16 numbers) are:
+ The interesting ones from above (deserving of abbreviations of
+ less than 16 numbers) are:
- n->n volume change (1 number)
- 1->n duplication (0 numbers)
- 2->1 mixdown (0 or 2 numbers)
- 2->2 balance (1 number)
- 2->2 fully general mix (4 numbers)
- 2->4 duplication (0 numbers)
- 4->1 mixdown (0 or 4 numbers)
- 4->2 mixdown (0 or 2 numbers)
- 4->4 balance (1 or 2 numbers)
+ n->n volume change (1 number)
+ 1->n duplication (0 numbers)
+ 2->1 mixdown (0 or 2 numbers)
+ 2->2 balance (1 number)
+ 2->2 fully general mix (4 numbers)
+ 2->4 duplication (0 numbers)
+ 4->1 mixdown (0 or 4 numbers)
+ 4->2 mixdown (0 or 2 numbers)
+ 4->4 balance (1 or 2 numbers)
- The above has one ambiguity: n->n volume change conflicts with
- n->n balance for n != 1. In such a case, we'll prefer
- balance, since there is already a volume effect in vol.c.
+ The above has one ambiguity: n->n volume change conflicts with
+ n->n balance for n != 1. In such a case, we'll prefer
+ balance, since there is already a volume effect in vol.c.
- GHK 2000/11/28
- */
- avg_t avg = (avg_t) effp->priv;
- double pans[16];
- int i;
- int ichan, ochan;
+ GHK 2000/11/28
+ */
+ avg_t avg = (avg_t) effp->priv;
+ double pans[16];
+ int i;
+ int ichan, ochan;
- for (i = 0; i < 16; i++)
- pans[i] = ((double*)&avg->sources[0][0])[i];
+ for (i = 0; i < 16; i++)
+ pans[i] = ((double*)&avg->sources[0][0])[i];
- ichan = effp->ininfo.channels;
- ochan = effp->outinfo.channels;
- if (ochan == -1) {
- st_fail("Output must have known number of channels to use avg effect");
- return(ST_EOF);
- }
+ ichan = effp->ininfo.channels;
+ ochan = effp->outinfo.channels;
+ if (ochan == -1) {
+ st_fail("Output must have known number of channels to use avg effect");
+ return(ST_EOF);
+ }
- if ((ichan != 1 && ichan != 2 && ichan != 4)
- || (ochan != 1 && ochan != 2 && ochan != 4)) {
- st_fail("Can't average %d channels into %d channels",
- ichan, ochan);
- return (ST_EOF);
- }
+ if ((ichan != 1 && ichan != 2 && ichan != 4)
+ || (ochan != 1 && ochan != 2 && ochan != 4)) {
+ st_fail("Can't average %d channels into %d channels",
+ ichan, ochan);
+ return (ST_EOF);
+ }
- /* Handle the special-case flags */
- switch (avg->mix) {
- case MIX_CENTER:
- if (ichan == ochan) {
- st_fail("Output must have different number of channels to use avg effect");
- return(ST_EOF);
- }
- break; /* Code below will handle this case */
- case MIX_LEFT:
- if (ichan < 2) {
- st_fail("Input must have at least two channels to use avg -l");
- return(ST_EOF);
- }
- pans[0] = 1.0;
- pans[1] = 0.0;
- avg->num_pans = 2;
- break;
- case MIX_RIGHT:
- if (ichan < 2) {
- st_fail("Input must have at least two channels to use avg -r");
- return(ST_EOF);
- }
- pans[0] = 0.0;
- pans[1] = 1.0;
- avg->num_pans = 2;
- break;
- case MIX_FRONT:
- if (ichan < 4) {
- st_fail("Input must have at four channels to use avg -f");
- return(ST_EOF);
- }
- pans[0] = 1.0;
- pans[1] = 0.0;
- avg->num_pans = 2;
- break;
- case MIX_BACK:
- if (ichan < 4) {
- st_fail("Input must have at four channels to use avg -b");
- return(ST_EOF);
- }
- pans[0] = 0.0;
- pans[1] = 1.0;
- avg->num_pans = 2;
- break;
- default:
- break;
- }
+ /* Handle the special-case flags */
+ switch (avg->mix) {
+ case MIX_CENTER:
+ if (ichan == ochan) {
+ st_fail("Output must have different number of channels to use avg effect");
+ return(ST_EOF);
+ }
+ break; /* Code below will handle this case */
+ case MIX_LEFT:
+ if (ichan < 2) {
+ st_fail("Input must have at least two channels to use avg -l");
+ return(ST_EOF);
+ }
+ pans[0] = 1.0;
+ pans[1] = 0.0;
+ avg->num_pans = 2;
+ break;
+ case MIX_RIGHT:
+ if (ichan < 2) {
+ st_fail("Input must have at least two channels to use avg -r");
+ return(ST_EOF);
+ }
+ pans[0] = 0.0;
+ pans[1] = 1.0;
+ avg->num_pans = 2;
+ break;
+ case MIX_FRONT:
+ if (ichan < 4) {
+ st_fail("Input must have at four channels to use avg -f");
+ return(ST_EOF);
+ }
+ pans[0] = 1.0;
+ pans[1] = 0.0;
+ avg->num_pans = 2;
+ break;
+ case MIX_BACK:
+ if (ichan < 4) {
+ st_fail("Input must have at four channels to use avg -b");
+ return(ST_EOF);
+ }
+ pans[0] = 0.0;
+ pans[1] = 1.0;
+ avg->num_pans = 2;
+ break;
+ default:
+ break;
+ }
- /* If the number of pans given is 4 or fewer, handle the special */
- /* cases listed in the comments above. The code is lengthy but */
- /* straightforward. */
- if (avg->num_pans == 0) {
- if (ichan == 1) {
- avg->sources[0][0] = 1.0;
- avg->sources[0][1] = 1.0;
- avg->sources[0][2] = 1.0;
- avg->sources[0][3] = 1.0;
- }
- else if (ichan == 2 && ochan == 1) {
- avg->sources[0][0] = 0.5;
- avg->sources[1][0] = 0.5;
- }
- else if (ichan == 2 && ochan == 4) {
- avg->sources[0][0] = 1.0;
- avg->sources[0][2] = 1.0;
- avg->sources[1][1] = 1.0;
- avg->sources[1][3] = 1.0;
- }
- else if (ichan == 4 && ochan == 1) {
- avg->sources[0][0] = 0.25;
- avg->sources[1][0] = 0.25;
- avg->sources[2][0] = 0.25;
- avg->sources[3][0] = 0.25;
- }
- else if (ichan == 4 && ochan == 2) {
- avg->sources[0][0] = 0.5;
- avg->sources[1][1] = 0.5;
- avg->sources[2][0] = 0.5;
- avg->sources[3][1] = 0.5;
- }
- else {
- st_fail("You must specify at least one mix level when using avg with an unusual number of channels.");
- return(ST_EOF);
- }
- }
- else if (avg->num_pans == 1) {
- /* Might be volume change or balance change */
- if ((ichan == 2 || ichan == 4) && ichan == ochan) {
- /* -1 is left only, 1 is right only */
- if (avg->sources[0][0] <= 0.0) {
- avg->sources[1][1] = pans[0] + 1.0;
- if (avg->sources[1][1] < 0.0)
- avg->sources[1][1] = 0.0;
- avg->sources[0][0] = 1.0;
- }
- else {
- avg->sources[0][0] = 1.0 - pans[0];
- if (avg->sources[0][0] < 0.0)
- avg->sources[0][0] = 0.0;
- avg->sources[1][1] = 1.0;
- }
- if (ichan == 4) {
- avg->sources[2][2] = avg->sources[0][0];
- avg->sources[3][3] = avg->sources[1][1];
- }
- }
- }
- else if (avg->num_pans == 2) {
- if (ichan == 2 && ochan == 1) {
- avg->sources[0][0] = pans[0];
- avg->sources[0][1] = 0.0;
- avg->sources[1][0] = pans[1];
- }
- else if (ichan == 4 && ochan == 2) {
- avg->sources[0][0] = pans[0];
- avg->sources[0][1] = 0.0;
- avg->sources[1][1] = pans[0];
- avg->sources[2][0] = pans[1];
- avg->sources[3][1] = pans[1];
- }
- else if (ichan == 4 && ochan == 4) {
- /* pans[0] is front -> front, pans[1] is for back */
- avg->sources[0][0] = pans[0];
- avg->sources[0][1] = 0.0;
- avg->sources[1][1] = pans[0];
- avg->sources[2][2] = pans[1];
- avg->sources[3][3] = pans[1];
- }
- }
- else if (avg->num_pans == 4) {
- if (ichan == 2 && ochan == 2) {
- /* Shorthand for 2-channel case */
- avg->sources[0][0] = pans[0];
- avg->sources[0][1] = pans[1];
- avg->sources[0][2] = 0.0;
- avg->sources[0][3] = 0.0;
- avg->sources[1][0] = pans[2];
- avg->sources[1][1] = pans[3];
- }
- else if (ichan == 4 && ochan == 1) {
- avg->sources[0][0] = pans[0];
- avg->sources[0][1] = 0.0;
- avg->sources[0][2] = 0.0;
- avg->sources[0][3] = 0.0;
- avg->sources[1][0] = pans[1];
- avg->sources[2][0] = pans[2];
- avg->sources[3][0] = pans[3];
- }
- }
- return (ST_SUCCESS);
+ /* If the number of pans given is 4 or fewer, handle the special */
+ /* cases listed in the comments above. The code is lengthy but */
+ /* straightforward. */
+ if (avg->num_pans == 0) {
+ if (ichan == 1) {
+ avg->sources[0][0] = 1.0;
+ avg->sources[0][1] = 1.0;
+ avg->sources[0][2] = 1.0;
+ avg->sources[0][3] = 1.0;
+ }
+ else if (ichan == 2 && ochan == 1) {
+ avg->sources[0][0] = 0.5;
+ avg->sources[1][0] = 0.5;
+ }
+ else if (ichan == 2 && ochan == 4) {
+ avg->sources[0][0] = 1.0;
+ avg->sources[0][2] = 1.0;
+ avg->sources[1][1] = 1.0;
+ avg->sources[1][3] = 1.0;
+ }
+ else if (ichan == 4 && ochan == 1) {
+ avg->sources[0][0] = 0.25;
+ avg->sources[1][0] = 0.25;
+ avg->sources[2][0] = 0.25;
+ avg->sources[3][0] = 0.25;
+ }
+ else if (ichan == 4 && ochan == 2) {
+ avg->sources[0][0] = 0.5;
+ avg->sources[1][1] = 0.5;
+ avg->sources[2][0] = 0.5;
+ avg->sources[3][1] = 0.5;
+ }
+ else {
+ st_fail("You must specify at least one mix level when using avg with an unusual number of channels.");
+ return(ST_EOF);
+ }
+ }
+ else if (avg->num_pans == 1) {
+ /* Might be volume change or balance change */
+ if ((ichan == 2 || ichan == 4) && ichan == ochan) {
+ /* -1 is left only, 1 is right only */
+ if (avg->sources[0][0] <= 0.0) {
+ avg->sources[1][1] = pans[0] + 1.0;
+ if (avg->sources[1][1] < 0.0)
+ avg->sources[1][1] = 0.0;
+ avg->sources[0][0] = 1.0;
+ }
+ else {
+ avg->sources[0][0] = 1.0 - pans[0];
+ if (avg->sources[0][0] < 0.0)
+ avg->sources[0][0] = 0.0;
+ avg->sources[1][1] = 1.0;
+ }
+ if (ichan == 4) {
+ avg->sources[2][2] = avg->sources[0][0];
+ avg->sources[3][3] = avg->sources[1][1];
+ }
+ }
+ }
+ else if (avg->num_pans == 2) {
+ if (ichan == 2 && ochan == 1) {
+ avg->sources[0][0] = pans[0];
+ avg->sources[0][1] = 0.0;
+ avg->sources[1][0] = pans[1];
+ }
+ else if (ichan == 4 && ochan == 2) {
+ avg->sources[0][0] = pans[0];
+ avg->sources[0][1] = 0.0;
+ avg->sources[1][1] = pans[0];
+ avg->sources[2][0] = pans[1];
+ avg->sources[3][1] = pans[1];
+ }
+ else if (ichan == 4 && ochan == 4) {
+ /* pans[0] is front -> front, pans[1] is for back */
+ avg->sources[0][0] = pans[0];
+ avg->sources[0][1] = 0.0;
+ avg->sources[1][1] = pans[0];
+ avg->sources[2][2] = pans[1];
+ avg->sources[3][3] = pans[1];
+ }
+ }
+ else if (avg->num_pans == 4) {
+ if (ichan == 2 && ochan == 2) {
+ /* Shorthand for 2-channel case */
+ avg->sources[0][0] = pans[0];
+ avg->sources[0][1] = pans[1];
+ avg->sources[0][2] = 0.0;
+ avg->sources[0][3] = 0.0;
+ avg->sources[1][0] = pans[2];
+ avg->sources[1][1] = pans[3];
+ }
+ else if (ichan == 4 && ochan == 1) {
+ avg->sources[0][0] = pans[0];
+ avg->sources[0][1] = 0.0;
+ avg->sources[0][2] = 0.0;
+ avg->sources[0][3] = 0.0;
+ avg->sources[1][0] = pans[1];
+ avg->sources[2][0] = pans[2];
+ avg->sources[3][0] = pans[3];
+ }
+ }
+ return (ST_SUCCESS);
}
/*
@@ -352,37 +346,35 @@
* Process either isamp or osamp samples, whichever is smaller.
*/
-int st_avg_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_avg_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
- avg_t avg = (avg_t) effp->priv;
- int len, done;
- int ichan, ochan;
- int i, j;
- double samp;
-
- ichan = effp->ininfo.channels;
- ochan = effp->outinfo.channels;
- len = *isamp / ichan;
- if (len > *osamp / ochan)
- len = *osamp / ochan;
- for (done = 0; done < len; done++, ibuf += ichan, obuf += ochan) {
- for (j = 0; j < ochan; j++) {
- samp = 0.0;
- for (i = 0; i < ichan; i++)
- samp += ibuf[i] * avg->sources[i][j];
- if (samp < -CLIP_LEVEL)
- samp = -CLIP_LEVEL;
- else if (samp > CLIP_LEVEL)
- samp = CLIP_LEVEL;
- obuf[j] = samp;
- }
- }
- *isamp = len * ichan;
- *osamp = len * ochan;
- return (ST_SUCCESS);
+ avg_t avg = (avg_t) effp->priv;
+ int len, done;
+ int ichan, ochan;
+ int i, j;
+ double samp;
+
+ ichan = effp->ininfo.channels;
+ ochan = effp->outinfo.channels;
+ len = *isamp / ichan;
+ if (len > *osamp / ochan)
+ len = *osamp / ochan;
+ for (done = 0; done < len; done++, ibuf += ichan, obuf += ochan) {
+ for (j = 0; j < ochan; j++) {
+ samp = 0.0;
+ for (i = 0; i < ichan; i++)
+ samp += ibuf[i] * avg->sources[i][j];
+ if (samp < -CLIP_LEVEL)
+ samp = -CLIP_LEVEL;
+ else if (samp > CLIP_LEVEL)
+ samp = CLIP_LEVEL;
+ obuf[j] = samp;
+ }
+ }
+ *isamp = len * ichan;
+ *osamp = len * ochan;
+ return (ST_SUCCESS);
}
/*
@@ -391,9 +383,8 @@
*
* Should have statistics on right, left, and output amplitudes.
*/
-int st_avg_stop(effp)
-eff_t effp;
+int st_avg_stop(eff_t effp)
{
- return (ST_SUCCESS); /* nothing to do */
+ return (ST_SUCCESS); /* nothing to do */
}
--- a/src/avr.c
+++ b/src/avr.c
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
#define AVR_MAGIC "2BIT"
--- a/src/band.c
+++ b/src/band.c
@@ -1,4 +1,3 @@
-
/*
* July 5, 1991
* Copyright 1991 Lance Norskog And Sundry Contributors
@@ -45,7 +44,7 @@
#include <math.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for Bandpass effect */
typedef struct bandstuff {
@@ -60,10 +59,7 @@
/*
* Process options
*/
-int st_band_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_band_getopts(eff_t effp, int n, char **argv)
{
band_t band = (band_t) effp->priv;
@@ -90,8 +86,7 @@
/*
* Prepare processing.
*/
-int st_band_start(effp)
-eff_t effp;
+int st_band_start(eff_t effp)
{
band_t band = (band_t) effp->priv;
if (band->center > effp->ininfo.rate/2)
@@ -117,10 +112,8 @@
* Return number of samples processed.
*/
-int st_band_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_band_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
band_t band = (band_t) effp->priv;
int len, done;
@@ -146,8 +139,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_band_stop(effp)
-eff_t effp;
+int st_band_stop(eff_t effp)
{
return (ST_SUCCESS); /* nothing to do */
}
--- a/src/bandpass.c
+++ b/src/bandpass.c
@@ -33,13 +33,10 @@
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#include "btrworth.h"
-int st_bandpass_getopts (effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_bandpass_getopts (eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -62,10 +59,7 @@
return (ST_SUCCESS);
}
-
-
-int st_bandpass_start (effp)
-eff_t effp;
+int st_bandpass_start (eff_t effp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
double c;
@@ -82,4 +76,3 @@
butterworth->b [1] = (c - 1.0) * butterworth->a[0];
return (ST_SUCCESS);
}
-
--- a/src/breject.c
+++ b/src/breject.c
@@ -33,7 +33,7 @@
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#include "btrworth.h"
int st_bandreject_getopts (effp, n, argv)
--- a/src/btrworth.c
+++ b/src/btrworth.c
@@ -33,11 +33,10 @@
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#include "btrworth.h"
-int st_butterworth_start (effp)
-eff_t effp;
+int st_butterworth_start (eff_t effp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -48,10 +47,8 @@
return (ST_SUCCESS);
}
-int st_butterworth_flow (effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_butterworth_flow (eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -98,4 +95,3 @@
*osamp = len;
return (ST_SUCCESS);
}
-
--- a/src/btrworth.h
+++ b/src/btrworth.h
@@ -32,8 +32,8 @@
*/
int st_butterworth_start (eff_t effp);
-int st_butterworth_flow (eff_t effp, LONG *ibuf, LONG *obuf,
- LONG *isamp, LONG *osamp);
+int st_butterworth_flow (eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp);
typedef struct butterworth {
double x [2];
--- a/src/cdr.c
+++ b/src/cdr.c
@@ -22,7 +22,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#define SECTORSIZE (2352 / 2)
@@ -39,8 +39,7 @@
* mono/stereo/quad.
*/
-int st_cdrstartread(ft)
-ft_t ft;
+int st_cdrstartread(ft_t ft)
{
int rc;
@@ -79,9 +78,7 @@
* Return number of samples read.
*/
-LONG st_cdrread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_cdrread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
return st_rawread(ft, buf, len);
@@ -91,15 +88,13 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_cdrstopread(ft)
-ft_t ft;
+int st_cdrstopread(ft_t ft)
{
/* Needed because of rawread() */
return st_rawstopread(ft);
}
-int st_cdrstartwrite(ft)
-ft_t ft;
+int st_cdrstartwrite(ft_t ft)
{
cdr_t cdr = (cdr_t) ft->priv;
int rc;
@@ -126,9 +121,7 @@
return(ST_SUCCESS);
}
-LONG st_cdrwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_cdrwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
cdr_t cdr = (cdr_t) ft->priv;
@@ -142,8 +135,7 @@
* samples. We write -32768 for each sample to pad it out.
*/
-int st_cdrstopwrite(ft)
-ft_t ft;
+int st_cdrstopwrite(ft_t ft)
{
cdr_t cdr = (cdr_t) ft->priv;
int padsamps = SECTORSIZE - (cdr->samples % SECTORSIZE);
@@ -167,4 +159,3 @@
}
return(ST_SUCCESS);
}
-
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -65,7 +65,7 @@
#include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
#include <math.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
#define MOD_SINE 0
#define MOD_TRIANGLE 1
@@ -76,12 +76,12 @@
int num_chorus;
int modulation[MAX_CHORUS];
int counter;
- long phase[MAX_CHORUS];
+ LONG phase[MAX_CHORUS];
float *chorusbuf;
float in_gain, out_gain;
float delay[MAX_CHORUS], decay[MAX_CHORUS];
float speed[MAX_CHORUS], depth[MAX_CHORUS];
- long length[MAX_CHORUS];
+ LONG length[MAX_CHORUS];
int *lookup_tab[MAX_CHORUS];
int depth_samples[MAX_CHORUS], samples[MAX_CHORUS];
int maxsamples, fade_out;
@@ -90,10 +90,7 @@
/*
* Process options
*/
-int st_chorus_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_chorus_getopts(eff_t effp, int n, char **argv)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
@@ -137,8 +134,7 @@
/*
* Prepare for processing.
*/
-int st_chorus_start(effp)
-eff_t effp;
+int st_chorus_start(eff_t effp)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
@@ -256,11 +252,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_chorus_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_chorus_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
chorus_t chorus = (chorus_t) effp->priv;
int len, done;
@@ -298,10 +291,7 @@
/*
* Drain out reverb lines.
*/
-int st_chorus_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_chorus_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
chorus_t chorus = (chorus_t) effp->priv;
int done;
@@ -341,8 +331,7 @@
/*
* Clean up chorus effect.
*/
-int st_chorus_stop(effp)
-eff_t effp;
+int st_chorus_stop(eff_t effp)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
--- a/src/compand.c
+++ b/src/compand.c
@@ -14,7 +14,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/*
* Compressor/expander effect for dsp.
@@ -57,9 +57,9 @@
double outgain; /* Post processor gain */
double delay; /* Delay to apply before companding */
LONG *delay_buf; /* Old samples, used for delay processing */
- long delay_buf_size; /* Size of delay_buf in samples */
- long delay_buf_ptr; /* Index into delay_buf */
- long delay_buf_cnt; /* No. of active entries in delay_buf */
+ LONG delay_buf_size; /* Size of delay_buf in samples */
+ LONG delay_buf_ptr; /* Index into delay_buf */
+ LONG delay_buf_cnt; /* No. of active entries in delay_buf */
} *compand_t;
/*
@@ -68,10 +68,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_compand_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_compand_getopts(eff_t effp, int n, char **argv)
{
compand_t l = (compand_t) effp->priv;
@@ -198,8 +195,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_compand_start(effp)
-eff_t effp;
+int st_compand_start(eff_t effp)
{
compand_t l = (compand_t) effp->priv;
int i;
@@ -275,11 +271,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_compand_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-int *isamp, *osamp;
+int st_compand_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
compand_t l = (compand_t) effp->priv;
int len = (*isamp > *osamp) ? *osamp : *isamp;
@@ -346,10 +339,7 @@
/*
* Drain out compander delay lines.
*/
-int st_compand_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_compand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
compand_t l = (compand_t) effp->priv;
int done;
@@ -372,8 +362,7 @@
/*
* Clean up compander effect.
*/
-int st_compand_stop(effp)
-eff_t effp;
+int st_compand_stop(eff_t effp)
{
compand_t l = (compand_t) effp->priv;
--- a/src/copy.c
+++ b/src/copy.c
@@ -11,16 +11,13 @@
* Sound Tools skeleton effect file.
*/
-#include "st.h"
+#include "st_i.h"
#include "string.h" /* memcpy() */
/*
* Process options
*/
-int st_copy_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_copy_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -33,8 +30,7 @@
/*
* Start processing
*/
-int st_copy_start(effp)
-eff_t effp;
+int st_copy_start(eff_t effp)
{
/* nothing to do */
/* stuff data into delaying effects here */
@@ -47,11 +43,8 @@
* Place in buf[].
* Return number of samples read.
*/
-
-int st_copy_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_copy_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
int done;
@@ -65,13 +58,8 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_copy_stop(effp)
-eff_t effp;
+int st_copy_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
}
-
-
-
-
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -45,8 +45,8 @@
#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
+#include "st_i.h"
#include "cvsdfilt.h"
-#include "st.h"
/* ---------------------------------------------------------------------- */
@@ -96,10 +96,7 @@
/* ---------------------------------------------------------------------- */
-static float float_conv(fp1, fp2, n)
-float *fp1;
-float *fp2;
-int n;
+static float float_conv(float *fp1, float *fp2,int n)
{
float res = 0;
for(; n > 0; n--)
@@ -119,8 +116,7 @@
*/
/* ---------------------------------------------------------------------- */
-static void cvsdstartcommon(ft)
-ft_t ft;
+static void cvsdstartcommon(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
@@ -162,8 +158,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstartread(ft)
-ft_t ft;
+int st_cvsdstartread(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
float *fp1;
@@ -189,8 +184,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstartwrite(ft)
-ft_t ft;
+int st_cvsdstartwrite(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
float *fp1;
@@ -212,8 +206,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstopwrite(ft)
-ft_t ft;
+int st_cvsdstopwrite(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
@@ -229,8 +222,7 @@
/* ---------------------------------------------------------------------- */
-int st_cvsdstopread(ft)
-ft_t ft;
+int st_cvsdstopread(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
@@ -252,9 +244,7 @@
} dbg = { NULL, NULL, 0 };
#endif
-LONG st_cvsdread(ft, buf, nsamp)
-ft_t ft;
-LONG *buf, nsamp;
+st_ssize_t st_cvsdread(ft_t ft, st_sample_t *buf, st_ssize_t nsamp)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
int done = 0;
@@ -334,9 +324,7 @@
/* ---------------------------------------------------------------------- */
-LONG st_cvsdwrite(ft, buf, nsamp)
-ft_t ft;
-LONG *buf, nsamp;
+st_ssize_t st_cvsdwrite(ft_t ft, st_sample_t *buf, st_ssize_t nsamp)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
int done = 0;
@@ -443,8 +431,7 @@
/* ---------------------------------------------------------------------- */
/* FIXME: Move these to misc.c */
-static ULONG get32(p)
-unsigned char **p;
+static ULONG get32(unsigned char **p)
{
ULONG val = (((*p)[3]) << 24) | (((*p)[2]) << 16) |
(((*p)[1]) << 8) | (**p);
@@ -452,8 +439,7 @@
return val;
}
-static unsigned get16(p)
-unsigned char **p;
+static unsigned get16(unsigned char **p)
{
unsigned val = (((*p)[1]) << 8) | (**p);
(*p) += 2;
@@ -460,9 +446,7 @@
return val;
}
-static void put32(p, val)
-unsigned char **p;
-ULONG val;
+static void put32(unsigned char **p, ULONG val)
{
*(*p)++ = val & 0xff;
*(*p)++ = (val >> 8) & 0xff;
@@ -470,9 +454,7 @@
*(*p)++ = (val >> 24) & 0xff;
}
-static void put16(p, val)
-unsigned char **p;
-unsigned val;
+static void put16(unsigned char **p, unsigned val)
{
*(*p)++ = val & 0xff;
*(*p)++ = (val >> 8) & 0xff;
@@ -480,9 +462,7 @@
/* ---------------------------------------------------------------------- */
-static int dvms_read_header(f, hdr)
-FILE *f;
-struct dvms_header *hdr;
+static int dvms_read_header(FILE *f, struct dvms_header *hdr)
{
unsigned char hdrbuf[DVMS_HEADER_LEN];
unsigned char *pch = hdrbuf;
@@ -527,9 +507,7 @@
/*
* note! file must be seekable
*/
-static int dvms_write_header(f, hdr)
-FILE *f;
-struct dvms_header *hdr;
+static int dvms_write_header(FILE *f, struct dvms_header *hdr)
{
unsigned char hdrbuf[DVMS_HEADER_LEN];
unsigned char *pch = hdrbuf;
@@ -572,9 +550,7 @@
/* ---------------------------------------------------------------------- */
-static void make_dvms_hdr(ft, hdr)
-ft_t ft;
-struct dvms_header *hdr;
+static void make_dvms_hdr(ft_t ft, struct dvms_header *hdr)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
int len;
@@ -600,8 +576,7 @@
/* ---------------------------------------------------------------------- */
-int st_dvmsstartread(ft)
-ft_t ft;
+int st_dvmsstartread(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
struct dvms_header hdr;
@@ -640,8 +615,7 @@
/* ---------------------------------------------------------------------- */
-int st_dvmsstartwrite(ft)
-ft_t ft;
+int st_dvmsstartwrite(ft_t ft)
{
struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
struct dvms_header hdr;
@@ -667,8 +641,7 @@
/* ---------------------------------------------------------------------- */
-int st_dvmsstopwrite(ft)
-ft_t ft;
+int st_dvmsstopwrite(ft_t ft)
{
struct dvms_header hdr;
int rc;
--- a/src/dat.c
+++ b/src/dat.c
@@ -20,7 +20,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
/* Private data for dat file */
typedef struct dat {
@@ -28,15 +28,13 @@
} *dat_t;
/* FIXME: Move this to misc.c */
-static LONG roundoff(x)
-double x;
+static LONG roundoff(double x)
{
if (x < 0.0) return(x - 0.5);
else return(x + 0.5);
}
-int st_datstartread(ft)
-ft_t ft;
+int st_datstartread(ft_t ft)
{
char inpstr[82];
char sc;
@@ -67,8 +65,7 @@
return (ST_SUCCESS);
}
-int st_datstartwrite(ft)
-ft_t ft;
+int st_datstartwrite(ft_t ft)
{
dat_t dat = (dat_t) ft->priv;
double srate;
@@ -96,9 +93,7 @@
return (ST_SUCCESS);
}
-LONG st_datread(ft, buf, nsamp)
-ft_t ft;
-LONG *buf, nsamp;
+st_ssize_t st_datread(ft_t ft, st_sample_t *buf, st_ssize_t nsamp)
{
char inpstr[82];
double sampval;
@@ -127,9 +122,7 @@
return (done);
}
-LONG st_datwrite(ft, buf, nsamp)
-ft_t ft;
-LONG *buf, nsamp;
+st_ssize_t st_datwrite(ft_t ft, st_sample_t *buf, st_ssize_t nsamp)
{
dat_t dat = (dat_t) ft->priv;
int done = 0;
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -11,7 +11,7 @@
* Cannot handle rate change.
*/
-#include "st.h"
+#include "st_i.h"
#include <math.h> /* exp(), sqrt() */
#include <limits.h> /* LONG_MAX */
@@ -49,10 +49,7 @@
/*
* Process options: dcshift (float) type (amplitude, power, dB)
*/
-int st_dcshift_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_dcshift_getopts(eff_t effp, int n, char **argv)
{
dcs_t dcs = (dcs_t) effp->priv;
dcs->dcshift = ONE; /* default is no change */
@@ -91,8 +88,7 @@
/*
* Start processing
*/
-int st_dcshift_start(effp)
-eff_t effp;
+int st_dcshift_start(eff_t effp)
{
dcs_t dcs = (dcs_t) effp->priv;
@@ -143,10 +139,8 @@
/*
* Process data.
*/
-int st_dcshift_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_dcshift_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
dcs_t dcs = (dcs_t) effp->priv;
register DCSHIFT_FLOAT dcshift = dcs->dcshift;
@@ -199,8 +193,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_dcshift_stop(effp)
-eff_t effp;
+int st_dcshift_stop(eff_t effp)
{
dcs_t dcs = (dcs_t) effp->priv;
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -99,7 +99,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for deemph file */
typedef struct deemphstuff {
@@ -113,10 +113,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_deemph_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_deemph_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -123,7 +120,7 @@
st_fail("Deemphasis filtering effect takes no options.\n");
return (ST_EOF);
}
- if (sizeof(double)*ST_MAX_PRIVSIZE < sizeof(struct deemphstuff))
+ if (sizeof(double)*ST_MAX_EFFECT_PRIVSIZE < sizeof(struct deemphstuff))
{
st_fail("Internal error: PRIVSIZE too small.\n");
return (ST_EOF);
@@ -135,8 +132,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_deemph_start(effp)
-eff_t effp;
+int st_deemph_start(eff_t effp)
{
/* check the input format */
if (effp->ininfo.encoding != ST_ENCODING_SIGN2
@@ -168,10 +164,8 @@
#define b0 0.45995451989513153057
#define b1 -0.08782333709141937339
-int st_deemph_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_deemph_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
deemph_t deemph = (deemph_t) effp->priv;
int len, done;
@@ -193,9 +187,7 @@
* Drain out remaining samples if the effect generates any.
*/
-int st_deemph_drain(effp, obuf, osamp)
-LONG *obuf;
-LONG *osamp;
+int st_deemph_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
/* nothing to do */
return (ST_SUCCESS);
@@ -205,8 +197,7 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-int st_deemph_stop(effp)
-eff_t effp;
+int st_deemph_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/earwax.c
+++ b/src/earwax.c
@@ -25,7 +25,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#define EARWAX_SCALE 64
@@ -75,10 +75,7 @@
/*
* Process options
*/
-int st_earwax_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_earwax_getopts(eff_t effp, int n, char **argv)
{
/* no options */
if (n){
@@ -91,8 +88,7 @@
/*
* Prepare for processing.
*/
-int st_earwax_start(effp)
-eff_t effp;
+int st_earwax_start(eff_t effp)
{
earwax_t earwax = (earwax_t) effp->priv;
int i;
@@ -126,10 +122,8 @@
* Return number of samples processed.
*/
-int st_earwax_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_earwax_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
earwax_t earwax = (earwax_t) effp->priv;
int len, done;
@@ -160,10 +154,7 @@
/*
* Drain out taps.
*/
-int st_earwax_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_earwax_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
earwax_t earwax = (earwax_t) effp->priv;
int i,j;
@@ -184,8 +175,7 @@
/*
* Clean up taps.
*/
-int st_earwax_stop(effp)
-eff_t effp;
+int st_earwax_stop(eff_t effp)
{
earwax_t earwax = (earwax_t) effp->priv;
--- a/src/echo.c
+++ b/src/echo.c
@@ -57,7 +57,7 @@
#include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
#define MAX_ECHOS 7 /* 24 bit x ( 1 + MAX_ECHOS ) = */
@@ -70,7 +70,7 @@
double *delay_buf;
float in_gain, out_gain;
float delay[MAX_ECHOS], decay[MAX_ECHOS];
- long samples[MAX_ECHOS], maxsamples, fade_out;
+ LONG samples[MAX_ECHOS], maxsamples, fade_out;
} *echo_t;
/* Private data for SKEL file */
@@ -79,10 +79,7 @@
/*
* Process options
*/
-int st_echo_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_echo_getopts(eff_t effp, int n, char **argv)
{
echo_t echo = (echo_t) effp->priv;
int i;
@@ -113,8 +110,7 @@
/*
* Prepare for processing.
*/
-int st_echo_start(effp)
-eff_t effp;
+int st_echo_start(eff_t effp)
{
echo_t echo = (echo_t) effp->priv;
int i;
@@ -186,11 +182,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_echo_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_echo_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
echo_t echo = (echo_t) effp->priv;
int len, done;
@@ -226,10 +219,7 @@
/*
* Drain out reverb lines.
*/
-int st_echo_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_echo_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
echo_t echo = (echo_t) effp->priv;
double d_in, d_out;
@@ -266,8 +256,7 @@
/*
* Clean up reverb effect.
*/
-int st_echo_stop(effp)
-eff_t effp;
+int st_echo_stop(eff_t effp)
{
echo_t echo = (echo_t) effp->priv;
--- a/src/echos.c
+++ b/src/echos.c
@@ -48,7 +48,7 @@
#include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
#define MAX_ECHOS 7 /* 24 bit x ( 1 + MAX_ECHOS ) = */
@@ -61,7 +61,7 @@
double *delay_buf;
float in_gain, out_gain;
float delay[MAX_ECHOS], decay[MAX_ECHOS];
- long samples[MAX_ECHOS], pointer[MAX_ECHOS], sumsamples;
+ LONG samples[MAX_ECHOS], pointer[MAX_ECHOS], sumsamples;
} *echos_t;
/* Private data for SKEL file */
@@ -69,10 +69,7 @@
/*
* Process options
*/
-int st_echos_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_echos_getopts(eff_t effp, int n, char **argv)
{
echos_t echos = (echos_t) effp->priv;
int i;
@@ -107,8 +104,7 @@
/*
* Prepare for processing.
*/
-int st_echos_start(effp)
-eff_t effp;
+int st_echos_start(eff_t effp)
{
echos_t echos = (echos_t) effp->priv;
int i;
@@ -178,11 +174,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_echos_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_echos_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
echos_t echos = (echos_t) effp->priv;
int len, done;
@@ -224,10 +217,7 @@
/*
* Drain out reverb lines.
*/
-int st_echos_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_echos_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
echos_t echos = (echos_t) effp->priv;
double d_in, d_out;
@@ -270,8 +260,7 @@
/*
* Clean up echos effect.
*/
-int st_echos_stop(effp)
-eff_t effp;
+int st_echos_stop(eff_t effp)
{
echos_t echos = (echos_t) effp->priv;
--- a/src/fade.c
+++ b/src/fade.c
@@ -22,7 +22,7 @@
#include <math.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for fade file */
typedef struct fadestuff
@@ -210,7 +210,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_fade_flow(eff_t effp, LONG *ibuf, LONG *obuf, int *isamp, int *osamp)
+int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
fade_t fade = (fade_t) effp->priv;
/* len is total samples, chcnt counts channels */
@@ -284,7 +285,7 @@
/*
* Drain out remaining samples if the effect generates any.
*/
-int st_fade_drain(eff_t effp, LONG *obuf, LONG *osamp)
+int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
fade_t fade = (fade_t) effp->priv;
int len, t_chan = 0;
--- a/src/filter.c
+++ b/src/filter.c
@@ -25,7 +25,7 @@
#include <string.h>
#include <stdlib.h>
-#include "st.h"
+#include "st_i.h"
#ifndef HAVE_MEMMOVE
#define memmove(dest,src,len) bcopy((src),(dest),(len))
@@ -59,10 +59,7 @@
/*
* Process options
*/
-int st_filter_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_filter_getopts(eff_t effp, int n, char **argv)
{
filter_t f = (filter_t) effp->priv;
@@ -112,8 +109,7 @@
/*
* Prepare processing.
*/
-int st_filter_start(effp)
-eff_t effp;
+int st_filter_start(eff_t effp)
{
filter_t f = (filter_t) effp->priv;
Float *Fp0, *Fp1;
@@ -191,11 +187,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_filter_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_filter_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
filter_t f = (filter_t) effp->priv;
LONG i, Nx, Nproc;
@@ -246,10 +239,7 @@
/*
* Process tail of input samples.
*/
-int st_filter_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_filter_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
filter_t f = (filter_t) effp->priv;
LONG isamp_res, *Obuf, osamp_res;
@@ -282,8 +272,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_filter_stop(effp)
-eff_t effp;
+int st_filter_stop(eff_t effp)
{
filter_t f = (filter_t) effp->priv;
@@ -292,14 +281,12 @@
return (ST_SUCCESS);
}
-static double jprod(Fp, Xp, ct)
-const Float Fp[], *Xp;
-LONG ct;
+static double jprod(const Float *Fp, const Float *Xp, LONG ct)
{
const Float *fp, *xp, *xq;
double v = 0;
- fp = Fp + ct; /* so sum starts with smaller coef's */
+ fp = Fp + ct; /* so sum starts with smaller coef's */
xp = Xp - ct;
xq = Xp + ct;
while (fp > Fp) { /* ct = 0 can happen */
@@ -310,9 +297,7 @@
return v;
}
-static void FiltWin(f, Nx)
-filter_t f;
-LONG Nx;
+static void FiltWin(filter_t f, LONG Nx)
{
Float *Y;
Float *X, *Xend;
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -55,7 +55,7 @@
#include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
#include <math.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
#define MOD_SINE 0
#define MOD_TRIANGLE 1
@@ -69,9 +69,9 @@
float in_gain, out_gain;
float delay, decay;
float speed;
- long length;
+ LONG length;
int *lookup_tab;
- long maxsamples, fade_out;
+ LONG maxsamples, fade_out;
} *flanger_t;
/* Private data for SKEL file */
@@ -79,10 +79,7 @@
/*
* Process options
*/
-int st_flanger_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_flanger_getopts(eff_t effp, int n, char **argv)
{
flanger_t flanger = (flanger_t) effp->priv;
@@ -115,8 +112,7 @@
/*
* Prepare for processing.
*/
-int st_flanger_start(effp)
-eff_t effp;
+int st_flanger_start(eff_t effp)
{
flanger_t flanger = (flanger_t) effp->priv;
int i;
@@ -209,11 +205,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_flanger_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_flanger_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
flanger_t flanger = (flanger_t) effp->priv;
int len, done;
@@ -247,10 +240,7 @@
/*
* Drain out reverb lines.
*/
-int st_flanger_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_flanger_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
flanger_t flanger = (flanger_t) effp->priv;
int done;
@@ -286,8 +276,7 @@
/*
* Clean up flanger effect.
*/
-int st_flanger_stop(effp)
-eff_t effp;
+int st_flanger_stop(eff_t effp)
{
flanger_t flanger = (flanger_t) effp->priv;
--- a/src/g721.c
+++ b/src/g721.c
@@ -49,7 +49,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#include "g72x.h"
#include "libst.h"
@@ -78,11 +78,7 @@
* Encodes the input vale of linear PCM, A-law or u-law data sl and returns
* the resulting code. -1 is returned for unknown input coding value.
*/
-int
-g721_encoder(sl, in_coding,state_ptr)
- int sl;
- int in_coding;
- struct g72x_state *state_ptr;
+int g721_encoder(int sl, int in_coding, struct g72x_state *state_ptr)
{
short sezi, se, sez; /* ACCUM */
short d; /* SUBTA */
@@ -135,11 +131,7 @@
* returns the resulting linear PCM, A-law or u-law value.
* return -1 for unknown out_coding value.
*/
-int
-g721_decoder(i, out_coding, state_ptr)
- int i;
- int out_coding;
- struct g72x_state *state_ptr;
+int g721_decoder(int i, int out_coding, struct g72x_state *state_ptr)
{
short sezi, sei, sez, se; /* ACCUM */
short y; /* MIX */
--- a/src/g723_24.c
+++ b/src/g723_24.c
@@ -37,7 +37,7 @@
* of workstation attributes, such as hardware 2's complement arithmetic.
*
*/
-#include "st.h"
+#include "st_i.h"
#include "libst.h"
#include "g72x.h"
@@ -65,11 +65,7 @@
* Encodes a linear PCM, A-law or u-law input sample and returns its 3-bit code.
* Returns -1 if invalid input coding value.
*/
-int
-g723_24_encoder(sl, in_coding, state_ptr)
- int sl;
- int in_coding;
- struct g72x_state *state_ptr;
+int g723_24_encoder(int sl, int in_coding, struct g72x_state *state_ptr)
{
short sei, sezi, se, sez; /* ACCUM */
short d; /* SUBTA */
@@ -120,11 +116,7 @@
* the resulting 16-bit linear PCM, A-law or u-law sample value.
* -1 is returned if the output coding is unknown.
*/
-int
-g723_24_decoder(i, out_coding, state_ptr)
- int i;
- int out_coding;
- struct g72x_state *state_ptr;
+int g723_24_decoder(int i, int out_coding, struct g72x_state *state_ptr)
{
short sezi, sei, sez, se; /* ACCUM */
short y; /* MIX */
--- a/src/g723_40.c
+++ b/src/g723_40.c
@@ -45,7 +45,7 @@
* the name of the module which it is implementing.
*
*/
-#include "st.h"
+#include "st_i.h"
#include "libst.h"
#include "g72x.h"
@@ -84,11 +84,7 @@
* the resulting 5-bit CCITT G.723 40Kbps code.
* Returns -1 if the input coding value is invalid.
*/
-int
-g723_40_encoder(sl, in_coding, state_ptr)
- int sl;
- int in_coding;
- struct g72x_state *state_ptr;
+int g723_40_encoder(int sl, int in_coding, struct g72x_state *state_ptr)
{
short sei, sezi, se, sez; /* ACCUM */
short d; /* SUBTA */
@@ -140,11 +136,7 @@
* the resulting 16-bit linear PCM, A-law or u-law sample value.
* -1 is returned if the output coding is unknown.
*/
-int
-g723_40_decoder( i, out_coding, state_ptr)
- int i;
- int out_coding;
- struct g72x_state *state_ptr;
+int g723_40_decoder(int i, int out_coding, struct g72x_state *state_ptr)
{
short sezi, sei, sez, se; /* ACCUM */
short y; /* MIX */
--- a/src/g72x.c
+++ b/src/g72x.c
@@ -30,7 +30,7 @@
* Common routines for G.721 and G.723 conversions.
*/
-#include "st.h"
+#include "st_i.h"
#include "libst.h"
#include "g72x.h"
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -51,7 +51,7 @@
#include <string.h>
-#include "st.h"
+#include "st_i.h"
/*
* get option letter from argument vector
@@ -65,10 +65,7 @@
#define tell(s) fputs(*nargv,stderr);fputs(s,stderr); \
fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
-int getopt(nargc,nargv,ostr)
-int nargc;
-char **nargv,
- *ostr;
+int getopt(int nargc, char **nargv, char *ostr)
{
static char *place = EMSG; /* option letter processing */
static char *lastostr = (char *) 0;
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -27,7 +27,7 @@
* Rewritten to support multiple channels
*/
-#include "st.h"
+#include "st_i.h"
#include "gsm.h"
#include <errno.h>
@@ -48,10 +48,7 @@
gsm handle[MAXCHANS];
};
-static int
-gsmstart_rw(ft,w)
-ft_t ft;
-int w; /* w != 0 is write */
+static int gsmstart_rw(ft_t ft, int w)
{
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
int ch;
@@ -86,14 +83,12 @@
return (ST_SUCCESS);
}
-int st_gsmstartread(ft)
-ft_t ft;
+int st_gsmstartread(ft_t ft)
{
return gsmstart_rw(ft,0);
}
-int st_gsmstartwrite(ft)
-ft_t ft;
+int st_gsmstartwrite(ft_t ft)
{
return gsmstart_rw(ft,1);
}
@@ -105,9 +100,7 @@
* Return number of samples read.
*/
-LONG st_gsmread(ft, buf, samp)
-ft_t ft;
-long *buf, samp;
+st_ssize_t st_gsmread(ft_t ft, st_sample_t *buf, st_ssize_t samp)
{
int done = 0;
int r, ch, chans;
@@ -149,8 +142,7 @@
return done;
}
-static int gsmflush(ft)
-ft_t ft;
+static int gsmflush(ft_t ft)
{
int r, ch, chans;
gsm_signal *gbuff;
@@ -185,9 +177,7 @@
return (ST_SUCCESS);
}
-LONG st_gsmwrite(ft, buf, samp)
-ft_t ft;
-long *buf, samp;
+st_ssize_t st_gsmwrite(ft_t ft, st_sample_t *buf, st_ssize_t samp)
{
int done = 0;
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
@@ -209,8 +199,7 @@
return done;
}
-int st_gsmstopread(ft)
-ft_t ft;
+int st_gsmstopread(ft_t ft)
{
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
int ch;
@@ -223,8 +212,7 @@
return (ST_SUCCESS);
}
-int st_gsmstopwrite(ft)
-ft_t ft;
+int st_gsmstopwrite(ft_t ft)
{
int rc;
struct gsmpriv *p = (struct gsmpriv *) ft->priv;
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -7,7 +7,7 @@
* the consequences of using this software.
*/
-#include "st.h"
+#include "st_i.h"
#include "btrworth.h"
/*
@@ -16,80 +16,50 @@
/* File format handlers. */
+/* SGI/Apple AIFF */
static char *aiffnames[] = {
"aiff",
"aif",
(char *) 0
};
-extern int st_aiffstartread();
-extern LONG st_aiffread();
-extern int st_aiffstopread();
-extern int st_aiffstartwrite();
-extern LONG st_aiffwrite();
-extern int st_aiffstopwrite();
-extern int st_aiffseek();
+/* a-law byte raw */
static char *alnames[] = {
"al",
(char *) 0
};
-extern int st_alstartread();
-extern int st_alstartwrite();
#if defined(ALSA_PLAYER)
+/* /dev/snd/pcmXX */
static char *alsanames[] = {
"alsa",
(char *) 0
};
-extern int st_alsastartread();
-extern int st_alsastartwrite();
#endif
+/* SPARC .au w/header */
static char *aunames[] = {
"au",
-#ifndef DOS
"snd",
-#endif
(char *) 0
};
-extern int st_austartread();
-extern LONG st_auread();
-extern int st_austartwrite();
-extern LONG st_auwrite();
-extern int st_austopwrite();
-extern int st_auseek();
-
static char *autonames[] = {
"auto",
(char *) 0
};
-extern int st_autostartread();
-extern int st_autostartwrite();
-
static char *avrnames[] = {
"avr",
(char *) 0
};
-extern int st_avrstartread();
-extern int st_avrstartwrite();
-extern LONG st_avrwrite();
-extern int st_avrstopwrite();
-
static char *cdrnames[] = {
"cdr",
(char *) 0
};
-extern int st_cdrstartread();
-extern LONG st_cdrread();
-extern int st_cdrstopread();
-extern int st_cdrstartwrite();
-extern LONG st_cdrwrite();
-extern int st_cdrstopwrite();
-
+/* Cont. Variable Slope Delta */
static char *cvsdnames[] = {
"cvs",
"cvsd",
@@ -96,23 +66,13 @@
(char *)0
};
-extern int st_cvsdstartread();
-extern LONG st_cvsdread();
-extern int st_cvsdstopread();
-extern int st_cvsdstartwrite();
-extern LONG st_cvsdwrite();
-extern int st_cvsdstopwrite();
-
+/* Text data samples */
static char *datnames[] = {
"dat",
(char *) 0
};
-extern int st_datstartread();
-extern LONG st_datread();
-extern int st_datstartwrite();
-extern LONG st_datwrite();
-
+/* Cont. Variable Solot Delta */
static char *dvmsnames[] = {
"vms",
"dvms",
@@ -119,68 +79,37 @@
(char *)0
};
-extern int st_dvmsstartread();
-extern int st_dvmsstartwrite();
-extern int st_dvmsstopwrite();
-
#ifdef HAVE_LIBGSM
+/* GSM 06.10 */
static char *gsmnames[] = {
"gsm",
(char *) 0
};
-
-extern int st_gsmstartread();
-extern LONG st_gsmread();
-extern int st_gsmstopread();
-extern int st_gsmstartwrite();
-extern LONG st_gsmwrite();
-extern int st_gsmstopwrite();
#endif
+/* Mac FSSD/HCOM */
static char *hcomnames[] = {
"hcom",
(char *) 0
};
-extern int st_hcomstartread();
-extern LONG st_hcomread();
-extern int st_hcomstopread();
-extern int st_hcomstartwrite();
-extern LONG st_hcomwrite();
-extern int st_hcomstopwrite();
-
+/* Amiga MAUD */
static char *maudnames[] = {
"maud",
(char *) 0,
};
-extern int st_maudstartread();
-extern LONG st_maudread();
-extern int st_maudstopread();
-extern LONG st_maudwrite();
-extern int st_maudstartwrite();
-extern int st_maudstopwrite();
-
static char *nulnames[] = {
"nul",
(char *) 0,
};
-extern int st_nulstartread();
-extern LONG st_nulread();
-extern int st_nulstopread();
-extern LONG st_nulwrite();
-extern int st_nulstartwrite();
-extern int st_nulstopwrite();
-
#if defined(OSS_PLAYER)
+/* OSS /dev/dsp player */
static char *ossdspnames[] = {
"ossdsp",
(char *) 0
};
-
-extern int st_ossdspstartread();
-extern int st_ossdspstartwrite();
#endif
static char *rawnames[] = {
@@ -195,516 +124,231 @@
(char *) 0
};
-extern int st_sbstartread();
-extern int st_sbstartwrite();
-
+/* IRCAM Sound File */
static char *sfnames[] = {
"sf",
(char *) 0
};
-extern int st_sfstartread();
-extern int st_sfstartwrite();
-extern int st_sfseek();
-
static char *slnames[] = {
"sl",
(char *) 0,
};
-extern int st_slstartread();
-extern int st_slstartwrite();
-
+/* SampleVision sound */
static char *smpnames[] = {
"smp",
(char *) 0,
};
-extern int st_smpstartread();
-extern LONG st_smpread();
-extern LONG st_smpwrite();
-extern int st_smpstartwrite();
-extern int st_smpstopwrite();
-extern int st_smpseek();
-
+/* Sndtool Sound File */
static char *sndtnames[] = {
"sndt",
-#ifdef DOS
- "snd",
-#endif
(char *) 0
};
-extern int st_sndtstartread();
-extern int st_sndtstartwrite();
-extern LONG st_sndtwrite();
-extern int st_sndtstopwrite();
-extern int st_sndseek();
-
+/* NIST Sphere File */
static char *spherenames[] = {
"sph",
(char *) 0
};
-extern int st_spherestartread();
-extern LONG st_sphereread();
-extern int st_spherestartwrite();
-extern LONG st_spherewrite();
-extern int st_spherestopwrite();
-
#if defined(SUNAUDIO_PLAYER)
+/* Sun /dev/audio player */
static char *sunnames[] = {
"sunau",
(char *) 0
};
-
-extern int st_sunstartread();
-extern int st_sunstartwrite();
#endif
+/* Amiga 8SVX */
static char *svxnames[] = {
"8svx",
(char *) 0
};
-extern int st_svxstartread();
-extern LONG st_svxread();
-extern int st_svxstopread();
-extern int st_svxstartwrite();
-extern LONG st_svxwrite();
-extern int st_svxstopwrite();
-
static char *swnames[] = {
"sw",
(char *) 0
};
-extern int st_swstartread();
-extern int st_swstartwrite();
-
+/* Yamaha TX16W and SY99 waves */
static char *txwnames[] = {
"txw",
(char *)0
};
-extern int st_txwstartread();
-extern LONG st_txwread();
-extern int st_txwstopread();
-extern int st_txwstartwrite();
-extern LONG st_txwwrite();
-extern int st_txwstopwrite();
-
static char *ubnames[] = {
"ub",
"sou",
"fssd",
-#ifdef MAC
- "snd",
-#endif
(char *) 0
};
-extern int st_ubstartread();
-extern int st_ubstartwrite();
-
static char *ulnames[] = {
"ul",
(char *) 0
};
-extern int st_ulstartread();
-extern int st_ulstartwrite();
-
static char *uwnames[] = {
"uw",
(char *) 0
};
-extern int st_uwstartread();
-extern int st_uwstartwrite();
-
+/* Sound Blaster .VOC */
static char *vocnames[] = {
"voc",
(char *) 0
};
-extern int st_vocstartread();
-extern LONG st_vocread();
-extern int st_vocstopread();
-extern int st_vocstartwrite();
-extern LONG st_vocwrite();
-extern int st_vocstopwrite();
-
#ifdef HAVE_LIBVORBIS
+/* Ogg Vorbis */
static char *vorbisnames[] = {
"vorbis",
"ogg",
(char *) 0
};
-
-extern int st_vorbisstartread();
-extern LONG st_vorbisread();
-extern int st_vorbisstopread();
-extern int st_vorbisstartwrite();
-extern LONG st_vorbiswrite();
-extern int st_vorbisstopwrite();
#endif
+/* Microsoftt RIFF */
static char *wavnames[] = {
"wav",
(char *) 0
};
-extern int st_wavstartread();
-extern LONG st_wavread();
-extern int st_wavstartwrite();
-extern LONG st_wavwrite();
-extern int st_wavstopwrite();
-extern int st_wavseek();
-
+/* Psion .wve */
static char *wvenames[] = {
"wve",
(char *) 0
};
-extern int st_wvestartread();
-extern LONG st_wveread();
-extern int st_wvestartwrite();
-extern LONG st_wvewrite();
-extern int st_wvestopwrite();
-extern int st_wveseek();
-extern int st_nothing();
-extern LONG st_nothing_success();
-
st_format_t st_formats[] = {
- {aiffnames, /* SGI/Apple AIFF */
-
- ST_FILE_STEREO | ST_FILE_LOOPS | ST_FILE_SEEK,
- st_aiffstartread, st_aiffread, st_aiffstopread,
- st_aiffstartwrite, st_aiffwrite, st_aiffstopwrite, st_aiffseek},
- {alnames, ST_FILE_STEREO, /* a-law byte raw */
- st_alstartread, st_rawread, st_rawstopread,
- st_alstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
-#if defined(ALSA_PLAYER)
- {alsanames, ST_FILE_STEREO, /* /dev/snd/pcmXX */
- st_alsastartread, st_rawread, st_rawstopread,
- st_alsastartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
+ {aiffnames,
+ ST_FILE_STEREO | ST_FILE_LOOPS | ST_FILE_SEEK,
+ st_aiffstartread, st_aiffread, st_aiffstopread,
+ st_aiffstartwrite, st_aiffwrite, st_aiffstopwrite, st_aiffseek},
+ {alnames, ST_FILE_STEREO,
+ st_alstartread, st_rawread, st_rawstopread,
+ st_alstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+#ifdef ALSA_PLAYER
+ {alsanames, ST_FILE_STEREO,
+ st_alsastartread, st_rawread, st_rawstopread,
+ st_alsastartwrite, st_rawwrite, st_rawstopwrite,
+ st_format_nothing_seek},
#endif
- {aunames, ST_FILE_STEREO | ST_FILE_SEEK, /* SPARC .au w/header */
- st_austartread, st_auread, st_rawstopread,
- st_austartwrite, st_auwrite, st_austopwrite, st_auseek},
- {autonames, ST_FILE_STEREO, /* Guess from header */
- st_autostartread, st_nothing_success, st_nothing,
- st_autostartwrite, st_nothing_success, st_nothing, st_nothing},
- {avrnames, ST_FILE_STEREO, /* AVR format */
- st_avrstartread, st_rawread, st_nothing,
- st_avrstartwrite, st_avrwrite, st_avrstopwrite, st_nothing},
- {cdrnames, ST_FILE_STEREO | ST_FILE_SEEK, /* CD-R format */
- st_cdrstartread, st_cdrread, st_cdrstopread,
- st_cdrstartwrite, st_cdrwrite, st_cdrstopwrite, st_rawseek},
- {cvsdnames, 0, /* Cont. Variable Slope Delta */
- st_cvsdstartread, st_cvsdread, st_cvsdstopread,
- st_cvsdstartwrite, st_cvsdwrite, st_cvsdstopwrite, st_nothing},
- {datnames, 0, /* Text data samples */
- st_datstartread, st_datread, st_nothing,
- st_datstartwrite, st_datwrite, st_nothing, st_nothing},
- {dvmsnames, 0, /* Cont. Variable Solot Delta */
- st_dvmsstartread, st_cvsdread, st_cvsdstopread,
- st_dvmsstartwrite, st_cvsdwrite, st_dvmsstopwrite, st_nothing},
+ {aunames, ST_FILE_STEREO | ST_FILE_SEEK,
+ st_austartread, st_auread, st_rawstopread,
+ st_austartwrite, st_auwrite, st_austopwrite,
+ st_auseek},
+ {autonames, ST_FILE_STEREO,
+ st_autostartread, st_format_nothing_io, st_format_nothing,
+ st_autostartwrite, st_format_nothing_io, st_format_nothing,
+ st_format_nothing_seek},
+ {avrnames, ST_FILE_STEREO,
+ st_avrstartread, st_rawread, st_format_nothing,
+ st_avrstartwrite, st_avrwrite, st_avrstopwrite,
+ st_format_nothing_seek},
+ {cdrnames, ST_FILE_STEREO | ST_FILE_SEEK,
+ st_cdrstartread, st_cdrread, st_cdrstopread,
+ st_cdrstartwrite, st_cdrwrite, st_cdrstopwrite,
+ st_rawseek},
+ {cvsdnames, 0,
+ st_cvsdstartread, st_cvsdread, st_cvsdstopread,
+ st_cvsdstartwrite, st_cvsdwrite, st_cvsdstopwrite,
+ st_format_nothing_seek},
+ {datnames, 0,
+ st_datstartread, st_datread, st_format_nothing,
+ st_datstartwrite, st_datwrite, st_format_nothing,
+ st_format_nothing_seek},
+ {dvmsnames, 0,
+ st_dvmsstartread, st_cvsdread, st_cvsdstopread,
+ st_dvmsstartwrite, st_cvsdwrite, st_dvmsstopwrite, st_format_nothing_seek},
#ifdef HAVE_LIBGSM
- {gsmnames, 0, /* GSM 06.10 */
- st_gsmstartread, st_gsmread, st_gsmstopread,
- st_gsmstartwrite, st_gsmwrite, st_gsmstopwrite, st_nothing},
+ {gsmnames, 0,
+ st_gsmstartread, st_gsmread, st_gsmstopread,
+ st_gsmstartwrite, st_gsmwrite, st_gsmstopwrite, st_format_nothing_seek},
#endif
- {hcomnames, 0, /* Mac FSSD/HCOM */
- st_hcomstartread, st_hcomread, st_hcomstopread,
- st_hcomstartwrite, st_hcomwrite, st_hcomstopwrite, st_nothing},
- {maudnames, ST_FILE_STEREO, /* Amiga MAUD */
- st_maudstartread, st_maudread, st_maudstopread,
- st_maudstartwrite, st_maudwrite, st_maudstopwrite, st_nothing},
- {nulnames, ST_FILE_STEREO, /* NUL */
- st_nulstartread, st_nulread, st_nulstopread,
- st_nulstartwrite, st_nulwrite, st_nulstopwrite},
-#if defined(OSS_PLAYER)
- {ossdspnames, ST_FILE_STEREO, /* OSS /dev/dsp player */
- st_ossdspstartread, st_rawread, st_rawstopread,
- st_ossdspstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
+ {hcomnames, 0,
+ st_hcomstartread, st_hcomread, st_hcomstopread,
+ st_hcomstartwrite, st_hcomwrite, st_hcomstopwrite, st_format_nothing_seek},
+ {maudnames, ST_FILE_STEREO,
+ st_maudstartread, st_maudread, st_maudstopread,
+ st_maudstartwrite, st_maudwrite, st_maudstopwrite, st_format_nothing_seek},
+ {nulnames, ST_FILE_STEREO,
+ st_nulstartread, st_nulread, st_nulstopread,
+ st_nulstartwrite, st_nulwrite, st_nulstopwrite, st_format_nothing_seek},
+#ifdef OSS_PLAYER
+ {ossdspnames, ST_FILE_STEREO,
+ st_ossdspstartread, st_rawread, st_rawstopread,
+ st_ossdspstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
#endif
- {rawnames, ST_FILE_STEREO | ST_FILE_SEEK, /* Raw format */
- st_rawstartread, st_rawread, st_rawstopread,
- st_rawstartwrite, st_rawwrite, st_rawstopwrite, st_rawseek},
- {sbnames, ST_FILE_STEREO, /* signed byte raw */
- st_sbstartread, st_rawread, st_rawstopread,
- st_sbstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
- {sfnames, ST_FILE_STEREO | ST_FILE_SEEK, /* IRCAM Sound File */
- st_sfstartread, st_rawread, st_rawstopread,
- st_sfstartwrite, st_rawwrite, st_rawstopwrite, st_sfseek},
- { slnames, ST_FILE_STEREO, /* signed long raw */
- st_slstartread, st_rawread, st_rawstopread,
- st_slstartwrite, st_rawwrite, st_rawstopwrite, st_nothing },
- {smpnames, ST_FILE_STEREO | ST_FILE_LOOPS | ST_FILE_SEEK,/* SampleVision sound */
- st_smpstartread, st_smpread, st_nothing,
- st_smpstartwrite, st_smpwrite, st_smpstopwrite, st_smpseek},
- {sndtnames, ST_FILE_STEREO | ST_FILE_SEEK, /* Sndtool Sound File */
- st_sndtstartread, st_rawread, st_rawstopread,
- st_sndtstartwrite, st_sndtwrite, st_sndtstopwrite, st_sndseek},
- {spherenames, ST_FILE_STEREO, /* NIST Sphere File */
- st_spherestartread, st_sphereread, st_rawstopread,
- st_spherestartwrite, st_spherewrite, st_spherestopwrite, st_nothing},
-#if defined(SUNAUDIO_PLAYER)
- {sunnames, ST_FILE_STEREO, /* Sun /dev/audio player */
- st_sunstartread, st_rawread, st_rawstopread,
- st_sunstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
+ {rawnames, ST_FILE_STEREO | ST_FILE_SEEK,
+ st_rawstartread, st_rawread, st_rawstopread,
+ st_rawstartwrite, st_rawwrite, st_rawstopwrite, st_rawseek},
+ {sbnames, ST_FILE_STEREO,
+ st_sbstartread, st_rawread, st_rawstopread,
+ st_sbstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+ {sfnames, ST_FILE_STEREO | ST_FILE_SEEK,
+ st_sfstartread, st_rawread, st_rawstopread,
+ st_sfstartwrite, st_rawwrite, st_rawstopwrite, st_sfseek},
+ { slnames, ST_FILE_STEREO,
+ st_slstartread, st_rawread, st_rawstopread,
+ st_slstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+ {smpnames, ST_FILE_STEREO | ST_FILE_LOOPS | ST_FILE_SEEK,
+ st_smpstartread, st_smpread, st_format_nothing,
+ st_smpstartwrite, st_smpwrite, st_smpstopwrite, st_smpseek},
+ {sndtnames, ST_FILE_STEREO | ST_FILE_SEEK,
+ st_sndtstartread, st_rawread, st_rawstopread,
+ st_sndtstartwrite, st_sndtwrite, st_sndtstopwrite, st_sndseek},
+ {spherenames, ST_FILE_STEREO,
+ st_spherestartread, st_sphereread, st_rawstopread,
+ st_spherestartwrite, st_spherewrite, st_spherestopwrite,
+ st_format_nothing_seek},
+#ifdef SUNAUDIO_PLAYER
+ {sunnames, ST_FILE_STEREO,
+ st_sunstartread, st_rawread, st_rawstopread,
+ st_sunstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
#endif
- {svxnames, ST_FILE_STEREO, /* Amiga 8SVX */
- st_svxstartread, st_svxread, st_svxstopread,
- st_svxstartwrite, st_svxwrite, st_svxstopwrite, st_nothing},
- {swnames, ST_FILE_STEREO, /* signed word raw */
- st_swstartread, st_rawread, st_rawstopread,
- st_swstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
- {txwnames, 0, /* Yamaha TX16W and SY99 waves */
- st_txwstartread, st_txwread, st_txwstopread,
- st_txwstartwrite, st_txwwrite, st_txwstopwrite, st_nothing},
- {ubnames, ST_FILE_STEREO, /* unsigned byte raw */
- st_ubstartread, st_rawread, st_rawstopread,
- st_ubstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
- {ulnames, ST_FILE_STEREO, /* u-law byte raw */
- st_ulstartread, st_rawread, st_rawstopread,
- st_ulstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
- {uwnames, ST_FILE_STEREO, /* unsigned word raw */
- st_uwstartread, st_rawread, st_rawstopread,
- st_uwstartwrite, st_rawwrite, st_rawstopwrite, st_nothing},
- {vocnames, ST_FILE_STEREO, /* Sound Blaster .VOC */
- st_vocstartread, st_vocread, st_vocstopread,
- st_vocstartwrite, st_vocwrite, st_vocstopwrite, st_nothing},
+ {svxnames, ST_FILE_STEREO,
+ st_svxstartread, st_svxread, st_svxstopread,
+ st_svxstartwrite, st_svxwrite, st_svxstopwrite, st_format_nothing_seek},
+ {swnames, ST_FILE_STEREO,
+ st_swstartread, st_rawread, st_rawstopread,
+ st_swstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+ {txwnames, 0,
+ st_txwstartread, st_txwread, st_txwstopread,
+ st_txwstartwrite, st_txwwrite, st_txwstopwrite, st_format_nothing_seek},
+ {ubnames, ST_FILE_STEREO,
+ st_ubstartread, st_rawread, st_rawstopread,
+ st_ubstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+ {ulnames, ST_FILE_STEREO,
+ st_ulstartread, st_rawread, st_rawstopread,
+ st_ulstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+ {uwnames, ST_FILE_STEREO,
+ st_uwstartread, st_rawread, st_rawstopread,
+ st_uwstartwrite, st_rawwrite, st_rawstopwrite, st_format_nothing_seek},
+ {vocnames, ST_FILE_STEREO,
+ st_vocstartread, st_vocread, st_vocstopread,
+ st_vocstartwrite, st_vocwrite, st_vocstopwrite, st_format_nothing_seek},
#ifdef HAVE_LIBVORBIS
- {vorbisnames, ST_FILE_STEREO, /* Ogg Vorbis */
- st_vorbisstartread, st_vorbisread, st_vorbisstopread,
- st_vorbisstartwrite, st_vorbiswrite, st_vorbisstopwrite},
+ {vorbisnames, ST_FILE_STEREO,
+ st_vorbisstartread, st_vorbisread, st_vorbisstopread,
+ st_vorbisstartwrite, st_vorbiswrite, st_vorbisstopwrite,
+ st_format_nothing_seek},
#endif
- {wavnames, ST_FILE_STEREO | ST_FILE_SEEK, /* Microsoftt RIFF */
- st_wavstartread, st_wavread, st_nothing,
- st_wavstartwrite, st_wavwrite, st_wavstopwrite, st_wavseek},
- {wvenames, ST_FILE_SEEK, /* Psion .wve */
- st_wvestartread, st_wveread, st_rawstopread,
- st_wvestartwrite, st_wvewrite, st_wvestopwrite, st_wveseek},
- {0, 0,
- 0, 0, 0, 0, 0, 0}
+ {wavnames, ST_FILE_STEREO | ST_FILE_SEEK,
+ st_wavstartread, st_wavread, st_format_nothing,
+ st_wavstartwrite, st_wavwrite, st_wavstopwrite, st_wavseek},
+ {wvenames, ST_FILE_SEEK,
+ st_wvestartread, st_wveread, st_rawstopread,
+ st_wvestartwrite, st_wvewrite, st_wvestopwrite, st_wveseek},
+ {0, 0,
+ 0, 0, 0, 0, 0, 0}
};
/* Effects handlers. */
-extern int st_null_drain(); /* dummy drain routine */
-
-extern int st_avg_getopts();
-extern int st_avg_start();
-extern int st_avg_flow();
-extern int st_avg_stop();
-
-extern int st_band_getopts();
-extern int st_band_start();
-extern int st_band_flow();
-extern int st_band_stop();
-extern int st_bandpass_getopts();
-extern int st_bandpass_start();
-
-extern int st_bandreject_getopts();
-extern int st_bandreject_start();
-
-extern int st_chorus_getopts();
-extern int st_chorus_start();
-extern int st_chorus_flow();
-extern int st_chorus_drain();
-extern int st_chorus_stop();
-
-extern int st_compand_getopts();
-extern int st_compand_start();
-extern int st_compand_flow();
-extern int st_compand_drain();
-extern int st_compand_stop();
-
-extern int st_copy_getopts();
-extern int st_copy_start();
-extern int st_copy_flow();
-extern int st_copy_stop();
-
-extern int st_dcshift_getopts();
-extern int st_dcshift_start();
-extern int st_dcshift_flow();
-extern int st_dcshift_stop();
-
-extern int st_deemph_getopts();
-extern int st_deemph_start();
-extern int st_deemph_flow();
-extern int st_deemph_stop();
-
-extern int st_echo_getopts();
-extern int st_echo_start();
-extern int st_echo_flow();
-extern int st_echo_drain();
-extern int st_echo_stop();
-
-extern int st_echos_getopts();
-extern int st_echos_start();
-extern int st_echos_flow();
-extern int st_echos_drain();
-extern int st_echos_stop();
-
-extern int st_earwax_getopts();
-extern int st_earwax_start();
-extern int st_earwax_flow();
-extern int st_earwax_drain();
-extern int st_earwax_stop();
-
-extern int st_fade_getopts();
-extern int st_fade_start();
-extern int st_fade_flow();
-extern int st_fade_drain();
-extern int st_fade_stop();
-
-extern int st_filter_getopts();
-extern int st_filter_start();
-extern int st_filter_flow();
-extern int st_filter_drain();
-extern int st_filter_stop();
-
-extern int st_flanger_getopts();
-extern int st_flanger_start();
-extern int st_flanger_flow();
-extern int st_flanger_drain();
-extern int st_flanger_stop();
-
-extern int st_highp_getopts();
-extern int st_highp_start();
-extern int st_highp_flow();
-extern int st_highp_stop();
-
-extern int st_highpass_getopts();
-extern int st_highpass_start();
-
-extern int st_lowp_getopts();
-extern int st_lowp_start();
-extern int st_lowp_flow();
-extern int st_lowp_stop();
-
-extern int st_lowpass_getopts();
-extern int st_lowpass_start();
-
-extern int st_map_getopts();
-extern int st_map_start();
-extern int st_map_flow();
-
-extern int st_mask_getopts();
-extern int st_mask_flow();
-
-extern int st_pan_getopts();
-extern int st_pan_start();
-extern int st_pan_flow();
-extern int st_pan_stop();
-
-extern int st_phaser_getopts();
-extern int st_phaser_start();
-extern int st_phaser_flow();
-extern int st_phaser_drain();
-extern int st_phaser_stop();
-
-extern int st_pick_getopts();
-extern int st_pick_start();
-extern int st_pick_flow();
-extern int st_pick_stop();
-
-extern int st_pitch_getopts();
-extern int st_pitch_start();
-extern int st_pitch_flow();
-extern int st_pitch_drain();
-extern int st_pitch_stop();
-
-extern int st_poly_getopts();
-extern int st_poly_start();
-extern int st_poly_flow();
-extern int st_poly_drain();
-extern int st_poly_stop();
-
-extern int st_rate_getopts();
-extern int st_rate_start();
-extern int st_rate_flow();
-extern int st_rate_stop();
-
-extern int st_resample_getopts();
-extern int st_resample_start();
-extern int st_resample_flow();
-extern int st_resample_drain();
-extern int st_resample_stop();
-
-extern int st_reverb_getopts();
-extern int st_reverb_start();
-extern int st_reverb_flow();
-extern int st_reverb_drain();
-extern int st_reverb_stop();
-
-extern int st_reverse_getopts();
-extern int st_reverse_start();
-extern int st_reverse_flow();
-extern int st_reverse_drain();
-extern int st_reverse_stop();
-
-extern int st_silence_getopts();
-extern int st_silence_start();
-extern int st_silence_flow();
-extern int st_silence_drain();
-extern int st_silence_stop();
-
-extern int st_speed_getopts();
-extern int st_speed_start();
-extern int st_speed_flow();
-extern int st_speed_drain();
-extern int st_speed_stop();
-
-extern int st_split_getopts();
-extern int st_split_start();
-extern int st_split_flow();
-extern int st_split_stop();
-
-extern int st_stat_getopts();
-extern int st_stat_start();
-extern int st_stat_flow();
-extern int st_stat_drain();
-extern int st_stat_stop();
-
-extern int st_stretch_getopts();
-extern int st_stretch_start();
-extern int st_stretch_flow();
-extern int st_stretch_drain();
-extern int st_stretch_stop();
-
-extern int st_swap_getopts();
-extern int st_swap_start();
-extern int st_swap_flow();
-extern int st_swap_drain();
-extern int st_swap_stop();
-
-extern int st_synth_getopts();
-extern int st_synth_start();
-extern int st_synth_flow();
-extern int st_synth_drain();
-extern int st_synth_stop();
-
-extern int st_trim_getopts();
-extern int st_trim_start();
-extern int st_trim_flow();
-extern int st_trim_stop();
-
-extern int st_vibro_getopts();
-extern int st_vibro_start();
-extern int st_vibro_flow();
-extern int st_vibro_stop();
-
-extern int st_vol_getopts();
-extern int st_vol_start();
-extern int st_vol_flow();
-extern int st_vol_stop();
-
/*
* ST_EFF_CHAN means that the number of channels can change.
* ST_EFF_RATE means that the sample rate can change.
@@ -713,21 +357,18 @@
*/
st_effect_t st_effects[] = {
- {"null", 0, /* stand-in, never gets called */
- st_nothing, st_nothing, st_nothing,
- st_null_drain, st_nothing},
{"avg", ST_EFF_CHAN,
st_avg_getopts, st_avg_start, st_avg_flow,
- st_null_drain, st_avg_stop},
+ st_effect_nothing_drain, st_avg_stop},
{"band", 0,
st_band_getopts, st_band_start, st_band_flow,
- st_null_drain, st_band_stop},
+ st_effect_nothing_drain, st_band_stop},
{"bandpass", 0,
st_bandpass_getopts, st_bandpass_start, st_butterworth_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"bandreject", 0,
st_bandreject_getopts, st_bandreject_start, st_butterworth_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"chorus", 0,
st_chorus_getopts, st_chorus_start, st_chorus_flow,
st_chorus_drain, st_chorus_stop},
@@ -736,13 +377,13 @@
st_compand_drain, st_compand_stop},
{"copy", ST_EFF_MCHAN,
st_copy_getopts, st_copy_start, st_copy_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"dcshift", ST_EFF_MCHAN,
st_dcshift_getopts, st_dcshift_start, st_dcshift_flow,
- st_null_drain, st_dcshift_stop},
+ st_effect_nothing_drain, st_dcshift_stop},
{"deemph", ST_EFF_MCHAN,
st_deemph_getopts, st_deemph_start, st_deemph_flow,
- st_null_drain, st_deemph_stop},
+ st_effect_nothing_drain, st_deemph_stop},
{"earwax", ST_EFF_MCHAN,
st_earwax_getopts, st_earwax_start, st_earwax_flow,
st_earwax_drain, st_earwax_stop},
@@ -763,31 +404,31 @@
st_flanger_drain, st_flanger_stop},
{"highp", 0,
st_highp_getopts, st_highp_start, st_highp_flow,
- st_null_drain, st_highp_stop},
+ st_effect_nothing_drain, st_highp_stop},
{"highpass", 0,
st_highpass_getopts, st_highpass_start, st_butterworth_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"lowp", 0,
st_lowp_getopts, st_lowp_start, st_lowp_flow,
- st_null_drain, st_lowp_stop},
+ st_effect_nothing_drain, st_lowp_stop},
{"lowpass", 0,
st_lowpass_getopts, st_lowpass_start, st_butterworth_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"map", ST_EFF_REPORT,
st_map_getopts, st_map_start, st_map_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"mask", ST_EFF_MCHAN,
- st_mask_getopts, st_nothing, st_mask_flow,
- st_null_drain, st_nothing},
+ st_mask_getopts, st_effect_nothing, st_mask_flow,
+ st_effect_nothing_drain, st_effect_nothing},
{"pan", ST_EFF_MCHAN | ST_EFF_CHAN,
st_pan_getopts, st_pan_start, st_pan_flow,
- st_null_drain, st_pan_stop},
+ st_effect_nothing_drain, st_pan_stop},
{"phaser", 0,
st_phaser_getopts, st_phaser_start, st_phaser_flow,
st_phaser_drain, st_phaser_stop},
{"pick", ST_EFF_MCHAN | ST_EFF_CHAN,
st_pick_getopts, st_pick_start, st_pick_flow,
- st_null_drain, st_pick_stop},
+ st_effect_nothing_drain, st_pick_stop},
{"pitch", 0,
st_pitch_getopts, st_pitch_start, st_pitch_flow,
st_pitch_drain, st_pitch_stop},
@@ -796,7 +437,7 @@
st_poly_drain, st_poly_stop},
{"rate", ST_EFF_RATE,
st_rate_getopts, st_rate_start, st_rate_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"resample", ST_EFF_RATE,
st_resample_getopts, st_resample_start, st_resample_flow,
st_resample_drain, st_resample_stop},
@@ -814,7 +455,7 @@
st_speed_flow, st_speed_drain, st_speed_stop},
{"split", ST_EFF_MCHAN | ST_EFF_CHAN,
st_split_getopts, st_split_start, st_split_flow,
- st_null_drain, st_split_stop},
+ st_effect_nothing_drain, st_split_stop},
{"stat", ST_EFF_MCHAN | ST_EFF_REPORT,
st_stat_getopts, st_stat_start, st_stat_flow,
st_stat_drain, st_stat_stop},
@@ -829,13 +470,13 @@
st_synth_drain, st_synth_stop},
{"trim", ST_EFF_MCHAN,
st_trim_getopts, st_trim_start, st_trim_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"vibro", 0,
st_vibro_getopts, st_vibro_start, st_vibro_flow,
- st_null_drain, st_nothing},
+ st_effect_nothing_drain, st_effect_nothing},
{"vol", ST_EFF_MCHAN,
st_vol_getopts, st_vol_start, st_vol_flow,
- st_null_drain, st_vol_stop},
+ st_effect_nothing_drain, st_vol_stop},
{0, 0, 0, 0, 0, 0, 0}
};
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -21,7 +21,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@@ -50,8 +50,7 @@
static int skipbytes(ft_t, int);
-int st_hcomstartread(ft)
-ft_t ft;
+int st_hcomstartread(ft_t ft)
{
struct readpriv *p = (struct readpriv *) ft->priv;
int i;
@@ -162,9 +161,7 @@
}
/* FIXME: Move to misc.c */
-static int skipbytes(ft, n)
-ft_t ft;
-int n;
+static int skipbytes(ft_t ft, int n)
{
unsigned char trash;
while (--n >= 0) {
@@ -177,9 +174,7 @@
return(ST_SUCCESS);
}
-LONG st_hcomread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_hcomread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
register struct readpriv *p = (struct readpriv *) ft->priv;
int done = 0;
@@ -246,8 +241,7 @@
return done;
}
-int st_hcomstopread(ft)
-ft_t ft;
+int st_hcomstopread(ft_t ft)
{
register struct readpriv *p = (struct readpriv *) ft->priv;
@@ -274,8 +268,7 @@
#define BUFINCR (10*BUFSIZ)
-int st_hcomstartwrite(ft)
-ft_t ft;
+int st_hcomstartwrite(ft_t ft)
{
register struct writepriv *p = (struct writepriv *) ft->priv;
@@ -312,9 +305,7 @@
return (ST_SUCCESS);
}
-LONG st_hcomwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_hcomwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
register struct writepriv *p = (struct writepriv *) ft->priv;
LONG datum;
@@ -359,8 +350,7 @@
static LONG codesize[256];
static LONG checksum;
-static void makecodes(e, c, s, b)
-int e, c, s, b;
+static void makecodes(int e, int c, int s, int b)
{
if(dictionary[e].dict_leftson < 0) {
codes[dictionary[e].dict_rightson] = c;
@@ -375,9 +365,7 @@
static int nbits;
/* FIXME: Place in misc.c */
-static void putlong(c, v)
-unsigned char *c;
-LONG v;
+static void putlong(unsigned char *c, LONG v)
{
*c++ = (v >> 24) & 0xff;
*c++ = (v >> 16) & 0xff;
@@ -385,9 +373,7 @@
*c++ = v & 0xff;
}
-static void putshort(c, v)
-unsigned char *c;
-short v;
+static void putshort(unsigned char *c, short v)
{
*c++ = (v >> 8) & 0xff;
*c++ = v & 0xff;
@@ -394,9 +380,7 @@
}
-static void putcode(c, df)
-unsigned char c;
-unsigned char ** df;
+static void putcode(unsigned char c, unsigned char **df)
{
LONG code, size;
int i;
@@ -417,10 +401,7 @@
}
}
-static int compress(df, dl, fr)
-unsigned char **df;
-LONG *dl;
-float fr;
+static int compress(unsigned char **df, LONG *dl, float fr)
{
LONG samplerate;
unsigned char *datafork = *df;
@@ -530,9 +511,7 @@
}
/* FIXME: Place in misc.c */
-static void padbytes(ft, n)
-ft_t ft;
-int n;
+static void padbytes(ft_t ft, int n)
{
while (--n >= 0)
st_writeb(ft, '\0');
@@ -541,8 +520,7 @@
/* End of hcom utility routines */
-int st_hcomstopwrite(ft)
-ft_t ft;
+int st_hcomstopwrite(ft_t ft)
{
register struct writepriv *p = (struct writepriv *) ft->priv;
unsigned char *compressed_data = p->data;
--- a/src/highp.c
+++ b/src/highp.c
@@ -30,7 +30,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for Highpass effect */
typedef struct highpstuff {
@@ -42,10 +42,7 @@
/*
* Process options
*/
-int st_highp_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_highp_getopts(eff_t effp, int n, char **argv)
{
highp_t highp = (highp_t) effp->priv;
@@ -60,8 +57,7 @@
/*
* Prepare processing.
*/
-int st_highp_start(effp)
-eff_t effp;
+int st_highp_start(eff_t effp)
{
highp_t highp = (highp_t) effp->priv;
if (highp->cutoff > effp->ininfo.rate/2)
@@ -82,11 +78,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_highp_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_highp_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
highp_t highp = (highp_t) effp->priv;
int len, done;
@@ -117,8 +110,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_highp_stop(effp)
-eff_t effp;
+int st_highp_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/highpass.c
+++ b/src/highpass.c
@@ -33,7 +33,7 @@
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#include "btrworth.h"
--- a/src/ima_rw.c
+++ b/src/ima_rw.c
@@ -23,7 +23,7 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include "st.h"
+#include "st_i.h"
#include "ima_rw.h"
/*
*
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -28,7 +28,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for Lowpass effect */
typedef struct lowpstuff {
@@ -40,10 +40,7 @@
/*
* Process options
*/
-int st_lowp_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_lowp_getopts(eff_t effp, int n, char **argv)
{
lowp_t lowp = (lowp_t) effp->priv;
@@ -58,8 +55,7 @@
/*
* Prepare processing.
*/
-int st_lowp_start(effp)
-eff_t effp;
+int st_lowp_start(eff_t effp)
{
lowp_t lowp = (lowp_t) effp->priv;
if (lowp->cutoff > effp->ininfo.rate / 2)
@@ -78,11 +74,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_lowp_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_lowp_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
lowp_t lowp = (lowp_t) effp->priv;
int len, done;
@@ -110,8 +103,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_lowp_stop(effp)
-eff_t effp;
+int st_lowp_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/lowpass.c
+++ b/src/lowpass.c
@@ -21,7 +21,7 @@
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#include "btrworth.h"
int st_lowpass_getopts (effp, n, argv)
--- a/src/map.c
+++ b/src/map.c
@@ -1,4 +1,3 @@
-
/*
* July 5, 1991
* Copyright 1991 Lance Norskog And Sundry Contributors
@@ -15,15 +14,12 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/*
* Process options
*/
-int st_map_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_map_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -36,15 +32,19 @@
/*
* Prepare processing.
*/
-int st_map_start(effp)
-eff_t effp;
+int st_map_start(eff_t effp)
{
int i;
fprintf(stderr, "Loop info:\n");
for(i = 0; i < 8; i++) {
+#ifdef __alpha__
fprintf(stderr, "Loop %d: start: %6d",i,effp->loops[i].start);
fprintf(stderr, " length: %6d", effp->loops[i].length);
+#else
+ fprintf(stderr, "Loop %d: start: %6ld",i,effp->loops[i].start);
+ fprintf(stderr, " length: %6ld", effp->loops[i].length);
+#endif
fprintf(stderr, " count: %6d", effp->loops[i].count);
fprintf(stderr, " type: ");
switch(effp->loops[i].type) {
@@ -63,11 +63,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_map_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_map_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
return (ST_SUCCESS);
}
--- a/src/mask.c
+++ b/src/mask.c
@@ -1,4 +1,3 @@
-
/*
* July 5, 1991
* Copyright 1991 Lance Norskog And Sundry Contributors
@@ -14,7 +13,7 @@
#include <stdlib.h>
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#define HALFABIT 1.44 /* square root of 2 */
@@ -28,10 +27,7 @@
/*
* Process options
*/
-int st_mask_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_mask_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -48,11 +44,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_mask_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_mask_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
int len, done;
--- a/src/maud.c
+++ b/src/maud.c
@@ -17,7 +17,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -41,8 +41,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_maudstartread(ft)
-ft_t ft;
+int st_maudstartread(ft_t ft)
{
struct maudstuff * p = (struct maudstuff *) ft->priv;
@@ -226,9 +225,7 @@
* Return number of samples read.
*/
-LONG st_maudread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_maudread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
return (st_rawread(ft, buf, len));
}
@@ -237,15 +234,13 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_maudstopread(ft)
-ft_t ft;
+int st_maudstopread(ft_t ft)
{
/* Needed because of rawread() */
return st_rawstopread(ft);
}
-int st_maudstartwrite(ft)
-ft_t ft;
+int st_maudstartwrite(ft_t ft)
{
struct maudstuff * p = (struct maudstuff *) ft->priv;
int rc;
@@ -287,9 +282,7 @@
return (ST_SUCCESS);
}
-LONG st_maudwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_maudwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
struct maudstuff * p = (struct maudstuff *) ft->priv;
@@ -298,8 +291,7 @@
return st_rawwrite(ft, buf, len);
}
-int st_maudstopwrite(ft)
-ft_t ft;
+int st_maudstopwrite(ft_t ft)
{
int rc;
@@ -321,8 +313,7 @@
}
#define MAUDHEADERSIZE (4+(4+4+32)+(4+4+32)+(4+4))
-static void maudwriteheader(ft)
-ft_t ft;
+static void maudwriteheader(ft_t ft)
{
struct maudstuff * p = (struct maudstuff *) ft->priv;
--- a/src/misc.c
+++ b/src/misc.c
@@ -11,7 +11,7 @@
* Sound Tools miscellaneous stuff.
*/
-#include "st.h"
+#include "st_i.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,6 +25,10 @@
#include <unistd.h>
#endif
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
const char *st_sizes_str[] = {
"NONSENSE!",
"bytes",
@@ -339,18 +343,14 @@
}
-/* dummy routines for do-nothing functions */
-void st_nothing(void) {}
-LONG st_nothing_success(void) {return(0);}
+/* dummy format routines for do-nothing functions */
+int st_format_nothing(ft_t ft) { return(ST_SUCCESS); }
+st_ssize_t st_format_nothing_io(ft_t ft, st_sample_t *buf, st_ssize_t len) { return(0); }
+int st_format_nothing_seek(ft_t ft, st_size_t offset) { return(ST_SUCCESS); }
-/* dummy drain routine for effects */
-void st_null_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
-{
- *osamp = 0;
-}
+/* dummy effect routine for do-nothing functions */
+int st_effect_nothing(eff_t effp) { return(ST_SUCCESS); }
+int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp) { *osamp = 0; return(ST_SUCCESS); }
/* here for linear interp. might be useful for other things */
LONG st_gcd(a, b)
--- a/src/oss.c
+++ b/src/oss.c
@@ -37,11 +37,10 @@
#include <machine/soundcard.h>
#endif
#include <sys/ioctl.h>
-#include "st.h"
+#include "st_i.h"
/* common r/w initialization code */
-static int ossdspinit(ft)
-ft_t ft;
+static int ossdspinit(ft_t ft)
{
int sampletype, samplesize, dsp_stereo;
int tmp, rc;
@@ -204,8 +203,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_ossdspstartread(ft)
-ft_t ft;
+int st_ossdspstartread(ft_t ft)
{
int rc;
rc = ossdspinit(ft);
@@ -213,8 +211,7 @@
return rc;
}
-int st_ossdspstartwrite(ft)
-ft_t ft;
+int st_ossdspstartwrite(ft_t ft)
{
return ossdspinit(ft);
}
--- a/src/pan.c
+++ b/src/pan.c
@@ -16,7 +16,7 @@
* pan 0.0 basically behaves as avg.
*/
-#include "st.h"
+#include "st_i.h"
/* should be taken care in st.h? */
#include <limits.h> /* LONG_MAX */
@@ -60,10 +60,7 @@
/*
* Process options
*/
-int st_pan_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_pan_getopts(eff_t effp, int n, char **argv)
{
pan_t pan = (pan_t) effp->priv;
@@ -83,8 +80,7 @@
/*
* Start processing
*/
-int st_pan_start(effp)
-eff_t effp;
+int st_pan_start(eff_t effp)
{
if (effp->outinfo.channels==1)
st_warn("PAN onto a mono channel...");
@@ -131,10 +127,8 @@
/*
* Process either isamp or osamp samples, whichever is smaller.
*/
-int st_pan_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_pan_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
pan_t pan = (pan_t) effp->priv;
register LONG len;
@@ -400,8 +394,7 @@
*
* Should have statistics on right, left, and output amplitudes.
*/
-int st_pan_stop(effp)
-eff_t effp;
+int st_pan_stop(eff_t effp)
{
pan_t pan = (pan_t) effp->priv;
if (pan->clipped) {
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -1,4 +1,3 @@
-
/*
* August 24, 1998
* Copyright (C) 1998 Juergen Mueller And Sundry Contributors
@@ -58,7 +57,7 @@
#include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
#include <math.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
#define MOD_SINE 0
#define MOD_TRIANGLE 1
@@ -72,18 +71,15 @@
float in_gain, out_gain;
float delay, decay;
float speed;
- long length;
+ LONG length;
int *lookup_tab;
- long maxsamples, fade_out;
+ LONG maxsamples, fade_out;
} *phaser_t;
/*
* Process options
*/
-int st_phaser_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_phaser_getopts(eff_t effp, int n, char **argv)
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -116,8 +112,7 @@
/*
* Prepare for processing.
*/
-int st_phaser_start(effp)
-eff_t effp;
+int st_phaser_start(eff_t effp)
{
phaser_t phaser = (phaser_t) effp->priv;
int i;
@@ -197,11 +192,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_phaser_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_phaser_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
phaser_t phaser = (phaser_t) effp->priv;
int len, done;
@@ -235,10 +227,7 @@
/*
* Drain out reverb lines.
*/
-int st_phaser_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_phaser_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
phaser_t phaser = (phaser_t) effp->priv;
int done;
@@ -274,8 +263,7 @@
/*
* Clean up phaser effect.
*/
-int st_phaser_stop(effp)
-eff_t effp;
+int st_phaser_stop(eff_t effp)
{
phaser_t phaser = (phaser_t) effp->priv;
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -35,7 +35,7 @@
* Some speed-optimization could be added at code size expanse/expense?
*/
-#include "st.h"
+#include "st_i.h"
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* memcpy() */
@@ -295,10 +295,7 @@
/*
* Process options
*/
-int st_pitch_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_pitch_getopts(eff_t effp, int n, char **argv)
{
pitch_t pitch = (pitch_t) effp->priv;
@@ -383,8 +380,7 @@
/*
* Start processing
*/
-int st_pitch_start(effp)
-eff_t effp;
+int st_pitch_start(eff_t effp)
{
pitch_t pitch = (pitch_t) effp->priv;
register int sample_rate = effp->outinfo.rate, i;
@@ -499,10 +495,8 @@
/* Processes input.
*/
-int st_pitch_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_pitch_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
pitch_t pitch = (pitch_t) effp->priv;
register int i, len, size, iindex, oindex;
@@ -571,10 +565,7 @@
/* at the end...
*/
-int st_pitch_drain(effp, obuf, osamp)
-eff_t effp;
-LONG * obuf;
-LONG * osamp;
+int st_pitch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
pitch_t pitch = (pitch_t) effp->priv;
register int i;
@@ -609,8 +600,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_pitch_stop(effp)
-eff_t effp;
+int st_pitch_stop(eff_t effp)
{
pitch_t pitch = (pitch_t) effp->priv;
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
#define Float float/*double*/
#define ISCALE 0x10000
@@ -546,7 +546,8 @@
return sample;
}
-int st_poly_flow(eff_t effp, LONG *ibuf, LONG *obuf, LONG *isamp, LONG *osamp)
+int st_poly_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
poly_t rate = (poly_t) effp->priv;
polystage *s0,*s1;
@@ -643,7 +644,7 @@
/*
* Process tail of input samples.
*/
-int st_poly_drain(eff_t effp, LONG *obuf, LONG *osamp)
+int st_poly_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
LONG in_size;
/* Call "flow" with NULL input. */
--- a/src/rate.c
+++ b/src/rate.c
@@ -17,7 +17,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/*
* Linear Interpolation.
@@ -53,10 +53,7 @@
/*
* Process options
*/
-int st_rate_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_rate_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -69,8 +66,7 @@
/*
* Prepare processing.
*/
-int st_rate_start(effp)
-eff_t effp;
+int st_rate_start(eff_t effp)
{
rate_t rate = (rate_t) effp->priv;
ULONG incr;
@@ -112,11 +108,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_rate_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_rate_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
rate_t rate = (rate_t) effp->priv;
LONG *istart,*iend;
@@ -172,8 +165,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_rate_stop(effp)
-eff_t effp;
+int st_rate_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
@@ -244,10 +236,7 @@
/*
* Process options
*/
-int st_rate_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_rate_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -260,8 +249,7 @@
/*
* Prepare processing.
*/
-int st_rate_start(effp)
-eff_t effp;
+int st_rate_start(eff_t effp)
{
rate_t rate = (rate_t) effp->priv;
@@ -281,11 +269,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_rate_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-int *isamp, *osamp;
+int st_rate_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
rate_t rate = (rate_t) effp->priv;
int len, done;
@@ -345,8 +330,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_rate_stop(effp)
-eff_t effp;
+int st_rate_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/raw.c
+++ b/src/raw.c
@@ -19,7 +19,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#include "libst.h"
#include <string.h>
@@ -38,10 +38,7 @@
static void rawdefaults(ft_t ft);
-
-int st_rawseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_rawseek(ft_t ft, st_size_t offset)
{
int sample_size = 0;
@@ -68,8 +65,7 @@
return(ft->st_errno);
}
-int st_rawstartread(ft)
-ft_t ft;
+int st_rawstartread(ft_t ft)
{
ft->file.buf = malloc(BUFSIZ);
if (!ft->file.buf)
@@ -85,8 +81,7 @@
return(ST_SUCCESS);
}
-int st_rawstartwrite(ft)
-ft_t ft;
+int st_rawstartwrite(ft_t ft)
{
ft->file.buf = malloc(BUFSIZ);
if (!ft->file.buf)
@@ -103,9 +98,7 @@
/* Util to reverse the n chars starting at p. */
/* FIXME: Move to misc.c */
-static void swapn(p, n)
-char *p;
-int n;
+static void swapn(char *p, int n)
{
char *q;
if (n>1) {
@@ -369,11 +362,13 @@
while (done < n)
{
- /* See if there is not enough data in buffer for any more reads.
+ /* See if there is not enough data in buffer for any more reads
+ * or if there is no data in the buffer at all.
* If not then shift any remaining data down to the beginning
- * and attempt to fill up the rest of the buffer.
+ * and attempt to fill up the rest of the buffer.
*/
- if (!ft->file.eof && ft->file.pos >= (ft->file.count-size+1))
+ if (!ft->file.eof && (ft->file.count == 0 ||
+ ft->file.pos >= (ft->file.count-size+1)))
{
for (i = 0; i < (ft->file.count-ft->file.pos); i++)
ft->file.buf[i] = ft->file.buf[ft->file.pos+i];
@@ -614,7 +609,8 @@
}
/* Possible overflow */
st_fail_errno(ft,ST_EFMT,"Sorry, don't have code to write %s, %s",
- st_encodings_str[ft->info.encoding], st_sizes_str[ft->info.size]);
+ st_encodings_str[(unsigned char)ft->info.encoding],
+ st_sizes_str[(unsigned char)ft->info.size]);
return 0;
}
--- a/src/resample.c
+++ b/src/resample.c
@@ -1,4 +1,3 @@
-
/*
* July 5, 1991
* Copyright 1991 Lance Norskog And Sundry Contributors
@@ -54,7 +53,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
/* resample includes */
#include "resampl.h"
@@ -114,10 +113,7 @@
/*
* Process options
*/
-int st_resample_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_resample_getopts(eff_t effp, int n, char **argv)
{
resample_t r = (resample_t) effp->priv;
@@ -175,8 +171,7 @@
/*
* Prepare processing.
*/
-int st_resample_start(effp)
-eff_t effp;
+int st_resample_start(eff_t effp)
{
resample_t r = (resample_t) effp->priv;
LONG Xoff, gcdrate;
@@ -271,11 +266,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_resample_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_resample_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
resample_t r = (resample_t) effp->priv;
LONG i, last, Nout, Nx, Nproc;
@@ -375,10 +367,7 @@
/*
* Process tail of input samples.
*/
-int st_resample_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_resample_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
resample_t r = (resample_t) effp->priv;
LONG isamp_res, *Obuf, osamp_res;
@@ -414,8 +403,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_resample_stop(effp)
-eff_t effp;
+int st_resample_stop(eff_t effp)
{
resample_t r = (resample_t) effp->priv;
@@ -427,10 +415,8 @@
/* over 90% of CPU time spent in this iprodUD() function */
/* quadratic interpolation */
-static double qprodUD(Imp, Xp, Inc, T0, dhb, ct)
-const Float Imp[], *Xp;
-LONG Inc, dhb, ct;
-double T0;
+static double qprodUD(const Float Imp[], const Float *Xp, LONG Inc, double T0,
+ LONG dhb, LONG ct)
{
const double f = 1.0/(1<<La);
double v;
@@ -461,10 +447,8 @@
}
/* linear interpolation */
-static double iprodUD(Imp, Xp, Inc, T0, dhb, ct)
-const Float Imp[], *Xp;
-LONG Inc, dhb, ct;
-double T0;
+static double iprodUD(const Float Imp[], const Float *Xp, LONG Inc,
+ double T0, LONG dhb, LONG ct)
{
const double f = 1.0/(1<<La);
double v;
@@ -491,9 +475,7 @@
/* From resample:filters.c */
/* Sampling rate conversion subroutine */
-static LONG SrcUD(r, Nx)
-resample_t r;
-LONG Nx;
+static LONG SrcUD(resample_t r, LONG Nx)
{
Float *Ystart, *Y;
double Factor;
@@ -538,9 +520,8 @@
}
/* exact coeff's */
-static double prodEX(Imp, Xp, Inc, T0, dhb, ct)
-const Float Imp[], *Xp;
-LONG Inc, T0, dhb, ct;
+static double prodEX(const Float Imp[], const Float *Xp,
+ LONG Inc, LONG T0, LONG dhb, LONG ct)
{
double v;
const Float *Cp;
@@ -556,9 +537,7 @@
return v;
}
-static LONG SrcEX(r, Nx)
-resample_t r;
-LONG Nx;
+static LONG SrcEX(resample_t r, LONG Nx)
{
Float *Ystart, *Y;
double Factor;
@@ -593,11 +572,8 @@
return (Y - Ystart); /* Return the number of output samples */
}
-int makeFilter(Imp, Nwing, Froll, Beta, Num, Normalize)
-Float Imp[];
-LONG Nwing, Num;
-int Normalize; /* non-zero to normalize DCGain of filter */
-double Froll, Beta;
+int makeFilter(Float Imp[], LONG Nwing, double Froll, double Beta,
+ LONG Num, int Normalize)
{
double *ImpR;
LONG Mwing, i;
@@ -684,8 +660,7 @@
#define IzeroEPSILON 1E-21 /* Max error acceptable in Izero */
-static double Izero(x)
-double x;
+static double Izero(double x)
{
double sum, u, halfx, temp;
LONG n;
@@ -702,9 +677,7 @@
return(sum);
}
-static void LpFilter(c,N,frq,Beta,Num)
-double c[], frq, Beta;
-LONG N, Num;
+static void LpFilter(double *c, LONG N, double frq, double Beta, LONG Num)
{
LONG i;
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -1,4 +1,3 @@
-
/*
* August 24, 1998
* Copyright (C) 1998 Juergen Mueller And Sundry Contributors
@@ -94,7 +93,7 @@
#include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#define REVERB_FADE_THRESH 10
#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
@@ -114,10 +113,7 @@
/*
* Process options
*/
-int st_reverb_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_reverb_getopts(eff_t effp, int n, char **argv)
{
reverb_t reverb = (reverb_t) effp->priv;
int i;
@@ -152,8 +148,7 @@
/*
* Prepare for processing.
*/
-int st_reverb_start(effp)
-eff_t effp;
+int st_reverb_start(eff_t effp)
{
reverb_t reverb = (reverb_t) effp->priv;
int i;
@@ -211,11 +206,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_reverb_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_reverb_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
reverb_t reverb = (reverb_t) effp->priv;
int len, done;
@@ -249,10 +241,7 @@
/*
* Drain out reverb lines.
*/
-int st_reverb_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_reverb_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
reverb_t reverb = (reverb_t) effp->priv;
float d_in, d_out;
@@ -288,8 +277,7 @@
/*
* Clean up reverb effect.
*/
-int st_reverb_stop(effp)
-eff_t effp;
+int st_reverb_stop(eff_t effp)
{
reverb_t reverb = (reverb_t) effp->priv;
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -1,4 +1,3 @@
-
/*
* June 1, 1992
* Copyright 1992 Guido van Rossum And Sundry Contributors
@@ -19,7 +18,7 @@
#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
-#include "st.h"
+#include "st_i.h"
/* Private data */
typedef struct reversestuff {
@@ -35,10 +34,7 @@
* Process options: none in our case.
*/
-int st_reverse_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_reverse_getopts(eff_t effp, int n, char **argv)
{
if (n)
{
@@ -52,8 +48,7 @@
* Prepare processing: open temporary file.
*/
-int st_reverse_start(effp)
-eff_t effp;
+int st_reverse_start(eff_t effp)
{
reverse_t reverse = (reverse_t) effp->priv;
reverse->fp = tmpfile();
@@ -70,11 +65,8 @@
* Effect flow: a degenerate case: write input samples on temporary file,
* don't generate any output samples.
*/
-
-int st_reverse_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_reverse_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
reverse_t reverse = (reverse_t) effp->priv;
@@ -97,10 +89,7 @@
* Effect drain: generate the actual samples in reverse order.
*/
-int st_reverse_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_reverse_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
reverse_t reverse = (reverse_t) effp->priv;
int len, nbytes;
@@ -143,8 +132,7 @@
/*
* Close and unlink the temporary file.
*/
-int st_reverse_stop(effp)
-eff_t effp;
+int st_reverse_stop(eff_t effp)
{
reverse_t reverse = (reverse_t) effp->priv;
--- a/src/sf.c
+++ b/src/sf.c
@@ -13,7 +13,7 @@
* Derived from: Sound Tools skeleton handler file.
*/
-#include "st.h"
+#include "st_i.h"
#include "sfircam.h"
#ifndef SIZEOF_BSD_HEADER
@@ -34,9 +34,7 @@
* Read the codes from the sound file, allocate space for the comment and
* assign its pointer to the comment field in ft.
*/
-static void readcodes(ft, sfhead)
-ft_t ft;
-SFHEADER *sfhead;
+static void readcodes(ft_t ft, SFHEADER *sfhead)
{
char *commentbuf = NULL, *sfcharp, *newline;
short bsize, finished = 0;
@@ -70,9 +68,7 @@
ft->comment = commentbuf;
}
-int st_sfseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_sfseek(ft_t ft, st_size_t offset)
{
sf_t sf = (sf_t ) ft->priv;
@@ -87,8 +83,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_sfstartread(ft)
-ft_t ft;
+int st_sfstartread(ft_t ft)
{
sf_t sf = (sf_t) ft->priv;
SFHEADER sfhead;
@@ -156,8 +151,7 @@
return(rc);
}
-int st_sfstartwrite(ft)
-ft_t ft;
+int st_sfstartwrite(ft_t ft)
{
sf_t sf = (sf_t) ft->priv;
SFHEADER sfhead;
@@ -215,6 +209,3 @@
}
/* Read and write are supplied by raw.c */
-
-
-
--- a/src/silence.c
+++ b/src/silence.c
@@ -14,7 +14,7 @@
#include <string.h>
#include <math.h>
-#include "st.h"
+#include "st_i.h"
#ifndef TRUE
#define TRUE 1
@@ -250,19 +250,25 @@
silence_t silence = (silence_t) effp->priv;
/* Now that we now sample rate, reparse duration. */
- if (st_parsesamples(effp->ininfo.rate, silence->stop_duration_str,
- &silence->stop_duration,'s') !=
- ST_SUCCESS)
+ if (silence->start)
{
- st_fail(SILENCE_USAGE);
- return(ST_EOF);
+ if (st_parsesamples(effp->ininfo.rate, silence->start_duration_str,
+ &silence->start_duration,'s') !=
+ ST_SUCCESS)
+ {
+ st_fail(SILENCE_USAGE);
+ return(ST_EOF);
+ }
}
- if (st_parsesamples(effp->ininfo.rate,silence->stop_duration_str,
- &silence->stop_duration,'s') !=
- ST_SUCCESS)
+ if (silence->stop)
{
- st_fail(SILENCE_USAGE);
- return(ST_EOF);
+ if (st_parsesamples(effp->ininfo.rate,silence->stop_duration_str,
+ &silence->stop_duration,'s') !=
+ ST_SUCCESS)
+ {
+ st_fail(SILENCE_USAGE);
+ return(ST_EOF);
+ }
}
if (silence->start)
@@ -283,7 +289,7 @@
return(ST_SUCCESS);
}
-int aboveThreshold(LONG value, double threshold, char unit)
+int aboveThreshold(st_sample_t value, double threshold, char unit)
{
double ratio;
int rc = 0;
@@ -308,8 +314,8 @@
/* Process signed long samples from ibuf to obuf. */
/* Return number of samples processed in isamp and osamp. */
-int st_silence_flow(eff_t effp, LONG *ibuf, LONG *obuf,
- LONG *isamp, LONG *osamp)
+int st_silence_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
silence_t silence = (silence_t) effp->priv;
int threshold, i, j;
@@ -524,7 +530,7 @@
return (ST_SUCCESS);
}
-int st_silence_drain(eff_t effp, LONG *obuf, LONG *osamp)
+int st_silence_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
silence_t silence = (silence_t) effp->priv;
int i;
--- a/src/skel.c
+++ b/src/skel.c
@@ -12,7 +12,7 @@
*/
#include <math.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for SKEL file */
typedef struct skelstuff {
@@ -26,8 +26,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_skelstartread(ft)
-ft_t ft;
+int st_skelstartread(ft_t ft)
{
skel_t sk = (skel_t) ft->priv;
@@ -57,9 +56,7 @@
* Return number of samples read.
*/
-LONG st_skelread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_skelread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
skel_t sk = (skel_t) ft->priv;
int abs;
@@ -89,20 +86,17 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int skelstopread(ft)
-ft_t ft;
+int skelstopread(ft_t ft)
{
return (ST_SUCCESS);
}
-int st_skelstartwrite(ft)
-ft_t ft;
+int st_skelstartwrite(ft_t ft)
{
skel_t sk = (skel_t) ft->priv;
/* If you have to seek around the output file */
- if (! ft->seekable)
- {
+ if (! ft->seekable) {
st_fail_errno(ft,ST_EVALUE,"Output .skel file must be a file, not a pipe");
return (ST_EOF);
}
@@ -118,9 +112,7 @@
}
-LONG st_skelwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_skelwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
skel_t sk = (skel_t) ft->priv;
register int datum;
@@ -136,8 +128,7 @@
}
-int st_skelstopwrite(ft)
-ft_t ft;
+int st_skelstopwrite(ft_t ft)
{
/* All samples are already written out. */
/* If file header needs fixing up, for example it needs the */
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -11,7 +11,7 @@
*/
-#include "st.h"
+#include "st_i.h"
/* Private data for SKEL file */
typedef struct skelleffstuff {
@@ -24,10 +24,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_skeleff_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_skeleff_getopts(eff_t effp, int n, char **argv)
{
skeleff_t skeleff = (skeleff_t) effp->priv;
@@ -46,8 +43,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_skeleff_start(effp)
-eff_t effp;
+int st_skeleff_start(eff_t effp)
{
if (effp->outinfo.channels == 1)
{
@@ -61,11 +57,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_skeleff_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_skeleff_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
skeleff_t skeleff = (skeleff_t) effp->priv;
int len, done;
@@ -99,9 +92,7 @@
* Drain out remaining samples if the effect generates any.
*/
-int st_skeleff_drain(effp, obuf, osamp)
-LONG *obuf;
-LONG *osamp;
+int st_skeleff_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
*osamp = 0;
return (ST_SUCCESS);
@@ -111,8 +102,7 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-int st_skeleff_stop(effp)
-eff_t effp;
+int st_skeleff_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/smp.c
+++ b/src/smp.c
@@ -16,7 +16,7 @@
* Add: Loop point verbose info. It's a start, anyway.
*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
#include <errno.h>
@@ -72,9 +72,7 @@
* Read the SampleVision trailer structure.
* Returns 1 if everything was read ok, 0 if there was an error.
*/
-static int readtrailer(ft, trailer)
-ft_t ft;
-struct smptrailer *trailer;
+static int readtrailer(ft_t ft, struct smptrailer *trailer)
{
int i;
ULONG trash;
@@ -109,10 +107,7 @@
/*
* set the trailer data - loops and markers, to reasonably benign values
*/
-static void settrailer(ft, trailer, rate)
-ft_t ft;
-struct smptrailer *trailer;
-unsigned int rate;
+static void settrailer(ft_t ft, struct smptrailer *trailer, ULONG rate)
{
int i;
@@ -146,9 +141,7 @@
* Write the SampleVision trailer structure.
* Returns 1 if everything was written ok, 0 if there was an error.
*/
-static int writetrailer(ft, trailer)
-ft_t ft;
-struct smptrailer *trailer;
+static int writetrailer(ft_t ft, struct smptrailer *trailer)
{
int i;
@@ -174,9 +167,7 @@
return(ST_SUCCESS);
}
-int st_smpseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_smpseek(ft_t ft, st_size_t offset)
{
smp_t smp = (smp_t) ft->priv;
@@ -194,8 +185,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_smpstartread(ft)
-ft_t ft;
+int st_smpstartread(ft_t ft)
{
smp_t smp = (smp_t) ft->priv;
int i;
@@ -326,9 +316,7 @@
* Place in buf[].
* Return number of samples read.
*/
-LONG st_smpread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_smpread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
smp_t smp = (smp_t) ft->priv;
unsigned short datum;
@@ -346,14 +334,12 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_smpstopread(ft)
-ft_t ft;
+int st_smpstopread(ft_t ft)
{
return(ST_SUCCESS);
}
-int st_smpstartwrite(ft)
-ft_t ft;
+int st_smpstartwrite(ft_t ft)
{
smp_t smp = (smp_t) ft->priv;
struct smpheader header;
@@ -394,9 +380,7 @@
return(ST_SUCCESS);
}
-LONG st_smpwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_smpwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
smp_t smp = (smp_t) ft->priv;
register int datum;
@@ -412,8 +396,7 @@
return(done);
}
-int st_smpstopwrite(ft)
-ft_t ft;
+int st_smpstopwrite(ft_t ft)
{
smp_t smp = (smp_t) ft->priv;
struct smptrailer trailer;
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -16,7 +16,7 @@
#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
-#include "st.h"
+#include "st_i.h"
/* Private data used by writer */
typedef struct sndpriv {
@@ -30,9 +30,7 @@
static void sndtwriteheader(ft_t ft,LONG nsamples);
-int st_sndseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_sndseek(ft_t ft, st_size_t offset)
{
snd_t snd = (snd_t ) ft->priv;
@@ -43,8 +41,7 @@
/* SNDSTARTREAD */
/*======================================================================*/
-int st_sndtstartread(ft)
-ft_t ft;
+int st_sndtstartread(ft_t ft)
{
snd_t snd = (snd_t ) ft->priv;
@@ -124,8 +121,7 @@
/*======================================================================*/
/* SNDTSTARTWRITE */
/*======================================================================*/
-int st_sndtstartwrite(ft)
-ft_t ft;
+int st_sndtstartwrite(ft_t ft)
{
snd_t p = (snd_t ) ft->priv;
int rc;
@@ -152,11 +148,11 @@
return(ST_SUCCESS);
}
+
/*======================================================================*/
/* SNDRSTARTWRITE */
/*======================================================================*/
-int st_sndrstartwrite(ft)
-ft_t ft;
+int st_sndrstartwrite(ft_t ft)
{
int rc;
@@ -191,9 +187,7 @@
/* SNDTWRITE */
/*======================================================================*/
-LONG st_sndtwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_sndtwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
snd_t p = (snd_t ) ft->priv;
p->nsamples += len;
@@ -204,8 +198,7 @@
/* SNDTSTOPWRITE */
/*======================================================================*/
-int st_sndtstopwrite(ft)
-ft_t ft;
+int st_sndtstopwrite(ft_t ft)
{
snd_t p = (snd_t ) ft->priv;
int rc;
@@ -230,9 +223,7 @@
/*======================================================================*/
/* SNDTWRITEHEADER */
/*======================================================================*/
-static void sndtwriteheader(ft,nsamples)
-ft_t ft;
-LONG nsamples;
+static void sndtwriteheader(ft_t ft, st_ssize_t nsamples)
{
char name_buf[97];
--- a/src/sox.c
+++ b/src/sox.c
@@ -26,7 +26,7 @@
*
*/
-#include "st.h"
+#include "st_i.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h> /* for malloc() */
@@ -260,7 +260,7 @@
{
int i1;
fprintf(stderr, "%s: Known effects: ",myname);
- for (i1 = 1; st_effects[i1].name; i1++)
+ for (i1 = 0; st_effects[i1].name; i1++)
fprintf(stderr, "%s ", st_effects[i1].name);
fprintf(stderr, "\n\n");
st_fail("Effect '%s' is not known!", argv[optind]);
@@ -318,7 +318,7 @@
*/
if (! strcmp(ft->filename, "-"))
ft->fp = stdin;
- else if ((ft->fp = fopen(ft->filename, READBINARY)) == NULL)
+ else if ((ft->fp = fopen(ft->filename, "rb")) == NULL)
st_fail("Can't open input file '%s': %s", ft->filename,
strerror(errno));
@@ -386,7 +386,7 @@
}
else {
- ft->fp = fopen(ft->filename, WRITEBINARY);
+ ft->fp = fopen(ft->filename, "wb");
if (ft->fp == NULL)
st_fail("Can't open output file '%s': %s",
@@ -416,7 +416,7 @@
static void doopts(ft_t ft, int argc, char **argv)
{
- int c;
+ int c, i;
char *str;
while ((c = getopt(argc, argv, getoptstr)) != -1) {
@@ -460,8 +460,9 @@
case 'c':
if (! ft) usage("-c");
str = optarg;
- if (! sscanf(str, "%d", &ft->info.channels))
+ if (! sscanf(str, "%d", &i))
st_fail("-c must be given a number");
+ ft->info.channels = i;
break;
case 'b':
if (! ft) usage("-b");
@@ -579,8 +580,8 @@
st_report("Input file %s: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
informat[f]->filename, informat[f]->info.rate,
- st_sizes_str[informat[f]->info.size],
- st_encodings_str[informat[f]->info.encoding],
+ st_sizes_str[(unsigned char)informat[f]->info.size],
+ st_encodings_str[(unsigned char)informat[f]->info.encoding],
informat[f]->info.channels,
(informat[f]->info.channels > 1) ? "channels" : "channel");
@@ -618,8 +619,8 @@
st_report("Output file %s: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
outformat->filename, outformat->info.rate,
- st_sizes_str[outformat->info.size],
- st_encodings_str[outformat->info.encoding],
+ st_sizes_str[(unsigned char)outformat->info.size],
+ st_encodings_str[(unsigned char)outformat->info.encoding],
outformat->info.channels,
(outformat->info.channels > 1) ? "channels" : "channel");
@@ -680,27 +681,12 @@
#ifndef SOXMIX
efftab[0].olen = (*informat[0]->h->read)(informat[0],
efftab[0].obuf, (LONG) BUFSIZ);
-
- if (informat[0]->st_errno)
- {
- st_warn("Error reading from %s: %s", informat[0]->filename,
- informat[0]->st_errstr);
- break;
- }
#else
for (f = 0; f < input_count; f++)
{
ilen[f] = (*informat[f]->h->read)(informat[f],
ibuf[f], (LONG)BUFSIZ);
- if (informat[f]->st_errno)
- {
- st_warn("Error reading from %s: %s", informat[f]->filename,
- informat[0]->st_errstr);
- break;
- }
}
- if (f < input_count && informat[f]->st_errno)
- break;
efftab[0].olen = 0;
for (f = 0; f < input_count; f++)
@@ -1194,7 +1180,7 @@
fprintf(stderr,"gopts: -e -h -p -v volume -V\n\n");
fprintf(stderr,"fopts: -r rate -c channels -s/-u/-U/-A/-a/-i/-g -b/-w/-l/-f/-d/-D -x\n\n");
fprintf(stderr, "effect: ");
- for (i = 1; st_effects[i].name != NULL; i++) {
+ for (i = 0; st_effects[i].name != NULL; i++) {
fprintf(stderr, "%s ", st_effects[i].name);
}
fprintf(stderr, "\n\neffopts: depends on effect\n\n");
@@ -1219,6 +1205,6 @@
/* remove the output file because we failed, if it's ours. */
/* Don't if its not a regular file. */
if (filetype(fileno(outformat->fp)) == S_IFREG)
- REMOVE(outformat->filename);
+ unlink(outformat->filename);
}
}
--- a/src/speed.c
+++ b/src/speed.c
@@ -11,7 +11,7 @@
* I think it is especially inefficient.
*/
-#include "st.h"
+#include "st_i.h"
#include <limits.h> /* LONG_MAX */
#include <math.h> /* pow */
@@ -111,10 +111,7 @@
}
/* get options. */
-int st_speed_getopts(effp, n, argv)
- eff_t effp;
- int n;
- char ** argv;
+int st_speed_getopts(eff_t effp, int n, char **argv)
{
speed_t speed = (speed_t) effp->priv;
int cent = 0;
@@ -144,8 +141,7 @@
}
/* start processing. */
-int st_speed_start(effp)
- eff_t effp;
+int st_speed_start(eff_t effp)
{
speed_t speed = (speed_t) effp->priv;
speed->clipped = 0;
@@ -203,7 +199,7 @@
/* interpolate values
*/
-static int compute(speed_t speed, LONG * obuf, int olen)
+static st_size_t compute(speed_t speed, st_sample_t *obuf, st_size_t olen)
{
register int i;
@@ -230,13 +226,11 @@
/* handle a flow.
*/
-int st_speed_flow(effp, ibuf, obuf, isamp, osamp)
- eff_t effp;
- LONG * ibuf, *obuf;
- LONG * isamp, * osamp;
+int st_speed_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
speed_t speed;
- register int len, iindex, oindex;
+ register st_size_t len, iindex, oindex;
speed = (speed_t) effp->priv;
@@ -271,10 +265,7 @@
/* end of stuff.
*/
-int st_speed_drain(effp, obuf, osamp)
- eff_t effp;
- LONG * obuf;
- LONG * osamp;
+int st_speed_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
speed_t speed = (speed_t) effp->priv;
register int i, oindex;
@@ -308,8 +299,7 @@
/* stop processing. report overflows.
*/
-int st_speed_stop(effp)
- eff_t effp;
+int st_speed_stop(eff_t effp)
{
speed_t speed = (speed_t) effp->priv;
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -12,7 +12,7 @@
#include <math.h>
#include <string.h>
#include <errno.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for SKEL file */
typedef struct spherestuff {
@@ -27,13 +27,13 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_spherestartread(ft)
-ft_t ft;
+int st_spherestartread(ft_t ft)
{
sphere_t sphere = (sphere_t) ft->priv;
int rc;
char buf[256];
char fldname[64], fldtype[16], fldsval[128];
+ int i;
int header_size, bytes_read;
/* Needed for rawread() */
@@ -71,12 +71,14 @@
{
if (strncmp(buf, "sample_n_bytes", 14) == 0 && ft->info.size == -1)
{
- sscanf(buf, "%s %s %d", fldname, fldtype, &ft->info.size);
+ sscanf(buf, "%s %s %d", fldname, fldtype, &i);
+ ft->info.size = i;
}
if (strncmp(buf, "channel_count", 13) == 0 &&
ft->info.channels == -1)
{
- sscanf(buf, "%s %s %d", fldname, fldtype, &ft->info.channels);
+ sscanf(buf, "%s %s %d", fldname, fldtype, &i);
+ ft->info.channels = i;
}
if (strncmp(buf, "sample_coding", 13) == 0)
{
@@ -180,9 +182,7 @@
* Return number of samples read.
*/
-LONG st_sphereread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_sphereread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
sphere_t sphere = (sphere_t) ft->priv;
@@ -196,8 +196,7 @@
return st_rawread(ft, buf, len);
}
-int st_spherestartwrite(ft)
-ft_t ft;
+int st_spherestartwrite(ft_t ft)
{
int rc;
int x;
@@ -236,9 +235,7 @@
}
-LONG st_spherewrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_spherewrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
sphere_t sphere = (sphere_t) ft->priv;
@@ -246,8 +243,7 @@
return st_rawwrite(ft, buf, len);
}
-int st_spherestopwrite(ft)
-ft_t ft;
+int st_spherestopwrite(ft_t ft)
{
int rc;
char buf[128];
--- a/src/st.h
+++ b/src/st.h
@@ -17,24 +17,40 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
+
+/* Release 12.17.3 of libst */
+#define ST_LIB_VERSION_CODE 0x0c1103
+#define ST_LIB_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+
+#ifdef __alpha__
+#include <sys/types.h> /* To get defines for exact size integers */
#endif
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
+
+#ifdef __alpha
+typedef int32_t st_sample_t;
+typdef uint32_t st_size_t;
+typedef int32_t st_ssize_t;
+typedef uint32t_t st_rate_t;
+#else
+typedef long st_sample_t;
+typedef unsigned long st_size_t;
+typedef long st_ssize_t;
+typedef unsigned long st_rate_t;
#endif
-/* Release 12.17.2 of libst */
-#define ST_LIB_VERSION_CODE 0x0c1102
-#define ST_LIB_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+/* Minimum and maximum values a sample can hold. */
+#define ST_SAMPLE_MAX 0x7fffffffL
+#define ST_SAMPLE_MIN (-ST_SAMPLE_MAX - 1L)
-/* SJB: these may be changed to assist fail-recovery in libST */
-#define st_malloc malloc
-#define st_free free
+/* Maximum value size type can hold. (Minimum is 0). */
+#define ST_SIZE_MAX 0xffffffffL
-/* FIXME: Move to separate header */
+/* Minimum and maximum value signed size type can hold. */
+#define ST_SSIZE_MAX 0x7fffffffL
+#define ST_SSIZE_MIN (-ST_SSIZE_MAX - 1L)
+
+/* FIXME: Remove from usage by libst */
#ifdef __alpha__
-#include <sys/types.h> /* To get defines for 32-bit integers */
#define LONG int32_t
#define ULONG u_int32_t
#else
@@ -42,61 +58,42 @@
#define ULONG unsigned long
#endif
+/* FIXME: Get rid of this and usage of LONG_MAX */
#define MAXLONG 0x7fffffffL
#define MAXULONG 0xffffffffL
-/* various gcc optimizations */
-#ifdef __GNUC__
-#define NORET __attribute__((noreturn))
-#define INLINE inline
-#else
-#define NORET
-#define INLINE
-#endif
-
-#ifdef USE_REGPARM
-#define REGPARM(n) __attribute__((regparm(n)))
-#else
-#define REGPARM(n)
-#endif
-
/* Signal parameters */
-/* FIXME: Change to typedef */
-typedef struct st_signalinfo {
- LONG rate; /* sampling rate */
- int size; /* word length of data */
- int encoding; /* format of sample numbers */
- int channels; /* number of sound channels */
+typedef struct st_signalinfo
+{
+ st_rate_t rate; /* sampling rate */
+ char size; /* word length of data */
+ char encoding; /* format of sample numbers */
+ char channels; /* number of sound channels */
} st_signalinfo_t;
/* Loop parameters */
-/* FIXME: Change to typedef */
-typedef struct st_loopinfo {
- int start; /* first sample */
- int length; /* length */
- int count; /* number of repeats, 0=forever */
- int type; /* 0=no, 1=forward, 2=forward/back */
-}st_loopinfo_t;
+typedef struct st_loopinfo
+{
+ st_size_t start; /* first sample */
+ st_size_t length; /* length */
+ unsigned int count; /* number of repeats, 0=forever */
+ char type; /* 0=no, 1=forward, 2=forward/back */
+} st_loopinfo_t;
/* Instrument parameters */
/* vague attempt at generic information for sampler-specific info */
-/* FIXME: Change to typedef */
-typedef struct st_instrinfo {
- char MIDInote; /* for unity pitch playback */
- char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
- char loopmode; /* semantics of loop data */
- char nloops; /* number of active loops */
- unsigned char smpte[4]; /* SMPTE offset (hour:min:sec:frame) */
- /* this is a film audio thing */
+typedef struct st_instrinfo
+{
+ char MIDInote; /* for unity pitch playback */
+ char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
+ char loopmode; /* semantics of loop data */
+ char nloops; /* number of active loops (max ST_MAX_NLOOPS) */
} st_instrinfo_t;
-
-#define ST_MIDI_UNITY 60 /* MIDI note number to play sample at unity */
-
/* Loop modes, upper 4 bits mask the loop blass, lower 4 bits describe */
/* the loop behaviour, ie. single shot, bidirectional etc. */
#define ST_LOOP_NONE 0
@@ -107,14 +104,14 @@
* File buffer info. Holds info so that data can be read in blocks.
*/
-/* FIXME: Change to typedef */
-typedef struct st_fileinfo {
- char *buf; /* Pointer to data buffer */
- int size; /* Size of buffer */
- int count; /* Count read in to buffer */
- int pos; /* Position in buffer */
- int eof; /* Marker that EOF has been reached */
-}st_fileinfo_t;
+typedef struct st_fileinfo
+{
+ char *buf; /* Pointer to data buffer */
+ st_size_t size; /* Size of buffer */
+ st_size_t count; /* Count read in to buffer */
+ st_size_t pos; /* Position in buffer */
+ unsigned char eof; /* Marker that EOF has been reached */
+} st_fileinfo_t;
/*
@@ -121,7 +118,8 @@
* Format information for input and output files.
*/
-#define ST_MAX_PRIVSIZE 330
+#define ST_MAX_FILE_PRIVSIZE 330
+#define ST_MAX_EFFECT_PRIVSIZE 330
#define ST_MAX_NLOOPS 8
@@ -132,51 +130,52 @@
typedef struct st_soundstream *ft_t;
typedef struct st_format {
- char **names; /* file type names */
- int flags; /* details about file type */
- int (*startread)(ft_t ft);
- LONG (*read)(ft_t ft, LONG *buf, LONG len);
- int (*stopread)(ft_t ft);
- int (*startwrite)(ft_t ft);
- LONG (*write)(ft_t ft, LONG *buf, LONG len);
- int (*stopwrite)(ft_t ft);
- int (*seek)(ft_t ft, LONG offset);
+ char **names;
+ unsigned int flags;
+ int (*startread)(ft_t ft);
+ st_ssize_t (*read)(ft_t ft, st_sample_t *buf, st_ssize_t len);
+ int (*stopread)(ft_t ft);
+ int (*startwrite)(ft_t ft);
+ st_ssize_t (*write)(ft_t ft, st_sample_t *buf, st_ssize_t len);
+ int (*stopwrite)(ft_t ft);
+ int (*seek)(ft_t ft, st_size_t offset);
} st_format_t;
struct st_soundstream {
- st_signalinfo_t info; /* signal specifications */
- st_instrinfo_t instr; /* instrument specification */
- st_loopinfo_t loops[ST_MAX_NLOOPS]; /* Looping specification */
- char swap; /* do byte- or word-swap */
- char seekable; /* can seek on this file */
- LONG length; /* estimate of total samples in file - for seeking*/
- char *filename; /* file name */
- char *filetype; /* type of file */
- char *comment; /* comment string */
- FILE *fp; /* File stream pointer */
- st_fileinfo_t file; /* File data block */
- int st_errno; /* Failure error codes */
- char st_errstr[256]; /* Extend Failure text */
- st_format_t *h; /* format struct for this file */
- /* The following is a portable trick to force the buffer to be
- * aligned on an 8-byte bounder on platforms that are really picky
- * about this. All pointer accesses to this data are always cast
- * to a structure so it doesn't really matter what we do declare
- * it as.
- */
- double priv[ST_MAX_PRIVSIZE/8]; /* format's private data area */
+ st_signalinfo_t info; /* signal specifications */
+ st_instrinfo_t instr; /* instrument specification */
+ st_loopinfo_t loops[ST_MAX_NLOOPS]; /* Looping specification */
+ char swap; /* do byte- or word-swap */
+ char seekable; /* can seek on this file */
+ st_size_t length; /* estimate of total samples in file - for seeking*/
+ char *filename; /* file name */
+ char *filetype; /* type of file */
+ char *comment; /* comment string */
+ FILE *fp; /* File stream pointer */
+ st_fileinfo_t file; /* File data block */
+ int st_errno; /* Failure error codes */
+ char st_errstr[256]; /* Extend Failure text */
+ st_format_t *h; /* format struct for this file */
+ /* The following is a portable trick to align this variable on
+ * an 8-byte bounder. Once this is done, the buffer alloced
+ * after it should be align on an 8-byte boundery as well.
+ * This lets you cast any structure over the private area
+ * without concerns of alignment.
+ */
+ double priv1;
+ char priv[ST_MAX_FILE_PRIVSIZE]; /* format's private data area */
};
extern st_format_t st_formats[];
/* file flags field */
-#define ST_FILE_STEREO 1 /* does file format support stereo? */
-#define ST_FILE_LOOPS 2 /* does file format support loops? */
-#define ST_FILE_INSTR 4 /* does file format support instrument specificications? */
-#define ST_FILE_SEEK 8 /* does file format support seeking? */
+#define ST_FILE_STEREO 1 /* does file format support stereo? */
+#define ST_FILE_LOOPS 2 /* does file format support loops? */
+#define ST_FILE_INSTR 4 /* does file format support instrument specs? */
+#define ST_FILE_SEEK 8 /* does file format support seeking? */
/* Size field */
-/* SJB: note that the 1st 3 are sometimes used as sizeof(type) */
+/* note that the 1st 3 are sometimes used as sizeof(type) */
#define ST_SIZE_BYTE 1
#define ST_SIZE_8BIT 1
#define ST_SIZE_WORD 2
@@ -215,129 +214,41 @@
typedef struct st_effect *eff_t;
-typedef struct {
- char *name; /* effect name */
- int flags; /* this and that */
- /* process arguments */
- int (*getopts)(eff_t effp, int argc, char **argv);
- /* start off effect */
- int (*start)(eff_t effp);
- /* do a buffer */
- int (*flow)(eff_t effp, LONG *ibuf, LONG *obuf,
- LONG *isamp, LONG *osamp);
- /* drain out at end */
- int (*drain)(eff_t effp, LONG *obuf, LONG *osamp);
- int (*stop)(eff_t effp); /* finish up effect */
+typedef struct
+{
+ char *name; /* effect name */
+ unsigned int flags;
+
+ int (*getopts)(eff_t effp, int argc, char **argv);
+ int (*start)(eff_t effp);
+ int (*flow)(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp);
+ int (*drain)(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
+ int (*stop)(eff_t effp);
} st_effect_t;
-struct st_effect {
- char *name; /* effect name */
- struct st_signalinfo ininfo; /* input signal specifications */
- struct st_loopinfo loops[8]; /* input loops specifications */
- struct st_instrinfo instr; /* input instrument specifications */
- struct st_signalinfo outinfo; /* output signal specifications */
- st_effect_t *h; /* effects driver */
- LONG *obuf; /* output buffer */
- LONG odone, olen; /* consumed, total length */
- /* The following is a portable trick to force the buffer to be
- * aligned on an 8-byte bounder on platforms that are really picky
- * about this. All pointer accesses to this data are always cast
- * to a structure so it doesn't really matter what we do declare
- * it as.
- */
- double priv[ST_MAX_PRIVSIZE/8]; /* private area for effect */
+struct st_effect
+{
+ char *name; /* effect name */
+ struct st_signalinfo ininfo; /* input signal specifications */
+ struct st_loopinfo loops[8]; /* input loops specifications */
+ struct st_instrinfo instr; /* input instrument specifications */
+ struct st_signalinfo outinfo; /* output signal specifications */
+ st_effect_t *h; /* effects driver */
+ st_sample_t *obuf; /* output buffer */
+ st_size_t odone, olen; /* consumed, total length */
+ /* The following is a portable trick to align this variable on
+ * an 8-byte bounder. Once this is done, the buffer alloced
+ * after it should be align on an 8-byte boundery as well.
+ * This lets you cast any structure over the private area
+ * without concerns of alignment.
+ */
+ double priv1;
+ char priv[ST_MAX_EFFECT_PRIVSIZE]; /* private area for effect */
};
extern st_effect_t st_effects[]; /* declared in handlers.c */
-/* declared in misc.c */
-extern LONG st_clip24(LONG) REGPARM(1);
-extern void st_sine(int *, LONG, int, int);
-extern void st_triangle(int *, LONG, int, int);
-
-extern LONG st_gcd(LONG,LONG) REGPARM(2);
-extern LONG st_lcm(LONG,LONG) REGPARM(2);
-
-/****************************************************/
-/* Prototypes for internal cross-platform functions */
-/****************************************************/
-/* SJB: shouldn't these be elsewhere, exported from misc.c */
-/* CB: Yep, we need to create something like a "platform.h" file for
- * these type functions.
- */
-#ifndef HAVE_RAND
-extern int rand(void);
-extern void srand(unsigned int seed);
-#endif
-extern void st_initrand(void);
-
-#ifndef HAVE_STRERROR
-char *strerror(int errorcode);
-#endif
-
-/* Read and write basic data types from "ft" stream. Uses ft->swap for
- * possible byte swapping.
- */
-/* declared in misc.c */
-LONG st_read(ft_t ft, void *buf, int size, LONG len);
-LONG st_write(ft_t ft, void *buf, int size, LONG len);
-int st_reads(ft_t ft, char *c, int len);
-int st_writes(ft_t ft, char *c);
-int st_readb(ft_t ft, unsigned char *uc);
-int st_writeb(ft_t ft, unsigned char uc);
-int st_readw(ft_t ft, unsigned short *us);
-int st_writew(ft_t ft, unsigned short us);
-int st_readdw(ft_t ft, ULONG *ul);
-int st_writedw(ft_t ft, ULONG ul);
-int st_readf(ft_t ft, float *f);
-int st_writef(ft_t ft, double f);
-int st_readdf(ft_t ft, double *d);
-int st_writedf(ft_t ft, double d);
-int st_seek(ft_t ft, LONG offset, int whence);
-LONG st_filelength(ft_t ft);
-
-/* FIXME: raw routines are used by so many formats their prototypes are defined
- * here for convience. This wont last for long so application software
- * shouldn't make use of it.
- */
-/* declared in raw.c */
-int st_rawstartread(ft_t ft);
-int st_rawstartwrite(ft_t ft);
-int st_rawstopread(ft_t ft);
-int st_rawstopwrite(ft_t ft);
-int st_rawseek(ft_t ft, LONG offset);
-LONG st_rawread(ft_t ft, LONG *buf, LONG nsamp);
-LONG st_rawwrite(ft_t ft, LONG *buf, LONG nsamp);
-
-/* Utilities to byte-swap values, use libc optimized macro's if possible */
-#ifdef HAVE_BYTESWAP_H
-#define st_swapw(x) bswap_16(x)
-#define st_swapl(x) bswap_32(x)
-#define st_swapf(x) (float)bswap_32((ULONG)(x))
-#else
-unsigned short st_swapw(unsigned short us); /* Swap short */
-ULONG st_swapl(ULONG ul); /* Swap long */
-float st_swapf(float f); /* Swap float */
-#endif
-double st_swapd(double d); /* Swap double */
-
-/* util.c */
-void st_report(const char *, ...);
-void st_warn(const char *, ...);
-void st_fail(const char *, ...) NORET;
-void st_fail_errno(ft_t, int, const char *, ...);
-
-int st_is_bigendian(void);
-int st_is_littleendian(void);
-
-#ifdef WORDS_BIGENDIAN
-#define ST_IS_BIGENDIAN 1
-#define ST_IS_LITTLEENDIAN 0
-#else
-#define ST_IS_BIGENDIAN st_is_bigendian()
-#define ST_IS_LITTLEENDIAN st_is_littleendian()
-#endif
-
int st_geteffect_opt(eff_t, int, char **);
int st_geteffect(eff_t, char *);
int st_checkeffect(char *);
@@ -346,7 +257,7 @@
void st_initformat(ft_t ft);
void st_copyformat(ft_t, ft_t);
int st_checkformat(ft_t);
-int st_parsesamples(ULONG rate, char *str, ULONG *samples, char def);
+int st_parsesamples(st_rate_t rate, char *str, st_size_t *samples, char def);
/* FIXME: Recording hacks shouldn't display a "sigint" style interface.
* Instead we should provide a function to call when done playing/recording.
@@ -354,33 +265,9 @@
*/
void sigintreg(ft_t);
-/* export flags */
-/* FIXME: these declared in util.c, inappropriate for lib */
+/* FIXME: these declared in util.c, global is inappropriate for lib */
extern int verbose; /* be noisy on stderr */
extern char *myname;
-
-extern int errno;
-/* Warning, this is a MAX value used in the library. Each format and
- * effect may have its own limitations of rate.
- */
-#define ST_MAXRATE 50L * 1024 /* maximum sample rate in library */
-
-/* FIXME: Move to internal st header */
-#define RIGHT(datum, bits) ((datum) >> bits)
-#define LEFT(datum, bits) ((datum) << bits)
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#endif
-
-
-/* FIXME: Move to platform header file */
-#define READBINARY "rb"
-#define WRITEBINARY "wb"
-#define REMOVE unlink
#define ST_EOF (-1)
#define ST_SUCCESS (0)
--- a/src/stat.c
+++ b/src/stat.c
@@ -18,7 +18,7 @@
#include <math.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for STAT effect */
typedef struct statstuff {
@@ -45,10 +45,7 @@
/*
* Process options
*/
-int st_stat_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_stat_getopts(eff_t effp, int n, char **argv)
{
stat_t stat = (stat_t) effp->priv;
@@ -106,8 +103,7 @@
/*
* Prepare processing.
*/
-int st_stat_start(effp)
-eff_t effp;
+int st_stat_start(eff_t effp)
{
stat_t stat = (stat_t) effp->priv;
int i;
@@ -167,10 +163,8 @@
extern int FFT(short dir,long m,double *x,double *y);
-int st_stat_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_stat_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
int len, done, x, x1;
@@ -268,10 +262,7 @@
/*
* Process tail of input samples.
*/
-int st_stat_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_stat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
int x;
@@ -320,8 +311,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_stat_stop(effp)
-eff_t effp;
+int st_stat_stop(eff_t effp)
{
stat_t stat = (stat_t) effp->priv;
double amp, scale, rms = 0, freq;
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -19,7 +19,7 @@
* It cannot handle different number of channels.
* It cannot handle rate change.
*/
-#include "st.h"
+#include "st_i.h"
#include <stdlib.h> /* malloc and free */
#include <limits.h> /* LONG_MAX */
@@ -127,10 +127,7 @@
/*
* Process options
*/
-int st_stretch_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_stretch_getopts(eff_t effp, int n, char **argv)
{
stretch_t stretch = (stretch_t) effp->priv;
@@ -208,8 +205,7 @@
/*
* Start processing
*/
-int st_stretch_start(effp)
-eff_t effp;
+int st_stretch_start(eff_t effp)
{
stretch_t stretch = (stretch_t) effp->priv;
register int i;
@@ -315,10 +311,8 @@
/*
* Processes flow.
*/
-int st_stretch_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_stretch_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
stretch_t stretch = (stretch_t) effp->priv;
register int iindex, oindex, i;
@@ -389,10 +383,7 @@
* Drain buffer at the end
* maybe not correct ? end might be artificially faded?
*/
-int st_stretch_drain(effp, obuf, osamp)
-eff_t effp;
-LONG *obuf;
-LONG *osamp;
+int st_stretch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
stretch_t stretch = (stretch_t) effp->priv;
register int i, oindex;
@@ -425,8 +416,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_stretch_stop(effp)
-eff_t effp;
+int st_stretch_stop(eff_t effp)
{
stretch_t stretch = (stretch_t) effp->priv;
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -31,7 +31,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
-#include "st.h"
+#include "st_i.h"
/*
* Do anything required before you start reading samples.
@@ -40,8 +40,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_sunstartread(ft)
-ft_t ft;
+int st_sunstartread(ft_t ft)
{
int samplesize, encoding;
audio_info_t audio_if;
@@ -176,8 +175,7 @@
return (ST_SUCCESS);
}
-int st_sunstartwrite(ft)
-ft_t ft;
+int st_sunstartwrite(ft_t ft)
{
int samplesize, encoding;
audio_info_t audio_if;
--- a/src/swap.c
+++ b/src/swap.c
@@ -11,7 +11,7 @@
*/
-#include "st.h"
+#include "st_i.h"
/* Private data for SKEL file */
typedef struct swapstuff {
@@ -24,10 +24,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_swap_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_swap_getopts(eff_t effp, int n, char **argv)
{
swap_t swap = (swap_t) effp->priv;
@@ -80,8 +77,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_swap_start(effp)
-eff_t effp;
+int st_swap_start(eff_t effp)
{
swap_t swap = (swap_t) effp->priv;
@@ -126,11 +122,8 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-
-int st_swap_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-int *isamp, *osamp;
+int st_swap_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
swap_t swap = (swap_t) effp->priv;
int len, done;
@@ -183,9 +176,7 @@
* Drain out remaining samples if the effect generates any.
*/
-int st_swap_drain(effp, obuf, osamp)
-LONG *obuf;
-int *osamp;
+int st_swap_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
*osamp = 0;
return (ST_SUCCESS);
@@ -195,8 +186,7 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-int st_swap_stop(effp)
-eff_t effp;
+int st_swap_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/synth.c
+++ b/src/synth.c
@@ -15,7 +15,7 @@
#include <limits.h>
#include <math.h>
#include <ctype.h>
-#include "st.h"
+#include "st_i.h"
#define USSTR ""\
"Usage:synth [length] type mix [freq[-freq2]] [off] [ph] [p1] [p2] [p3]\n"\
@@ -230,10 +230,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_synth_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_synth_getopts(eff_t effp, int n, char **argv)
{
int argn;
char *usstr=USSTR;
@@ -426,8 +423,7 @@
* Prepare processing.
* Do all initializations.
*/
-int st_synth_start(effp)
-eff_t effp;
+int st_synth_start(eff_t effp)
{
int i;
int c;
@@ -696,11 +692,8 @@
/*
* Processed signed long samples from ibuf to obuf.
*/
-
-int st_synth_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_synth_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
synth_t synth = (synth_t) effp->priv;
int len; /* number of input samples */
@@ -746,9 +739,7 @@
* Drain out remaining samples if the effect generates any.
*/
-int st_synth_drain(effp, obuf, osamp)
-LONG *obuf;
-LONG *osamp;
+int st_synth_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
*osamp = 0;
return (ST_SUCCESS);
@@ -758,8 +749,7 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-int st_synth_stop(effp)
-eff_t effp;
+int st_synth_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/tests.sh
+++ b/src/tests.sh
@@ -1,19 +1,190 @@
#!/bin/sh
#
-# SOX Test script. This should run without core-dumping or printing any
-# messages from the compare program.
+# SOX Test script.
#
-# This script is manual just quick sanity check of SOX.
+# This script is just a quick sanity check of SOX on lossless conversions.
-file=monkey
-
# verbose options
#noise=-V
-rm -f out.raw out2.raw in.raw
-./sox $noise $file.voc ub.raw
-./sox $noise -t raw -r 8196 -u -b -c 1 ub.raw -r 8196 -s -b sb.raw
-./sox $noise -t raw -r 8196 -s -b -c 1 sb.raw -r 8196 -u -b ub2.raw
+./sox $noise monkey.au raw1.ub
+
+# Convert between unsigned bytes and signed bytes
+./sox $noise -r 8012 -c 1 raw1.ub raw1.sb
+./sox $noise -r 8012 -c 1 raw1.sb raw2.ub
+if cmp -s raw1.ub raw2.ub
+then
+ echo "Conversion between unsigned bytes and signed bytes was successful"
+else
+ echo "Error converting between signed and unsigned bytes"
+fi
+rm -f raw1.sb raw2.ub
+
+./sox $noise -r 8012 -c 1 raw1.ub raw1.sw
+./sox $noise -r 8012 -c 1 raw1.sw raw2.ub
+if cmp -s raw1.ub raw2.ub
+then
+ echo "Conversion between unsigned bytes and signed words was successful"
+else
+ echo "Error converting between signed words and unsigned bytes"
+fi
+rm -f raw1.sw raw2.ub
+
+./sox $noise -r 8012 -c 1 raw1.ub raw1.uw
+./sox $noise -r 8012 -c 1 raw1.uw raw2.ub
+if cmp -s raw1.ub raw2.ub
+then
+ echo "Conversion between unsigned bytes and unsigned words was successful"
+else
+ echo "Error converting between unsigned words and unsigned bytes"
+fi
+rm -f raw1.uw raw2.ub
+
+./sox $noise -r 8012 -c 1 raw1.ub raw1.sl
+./sox $noise -r 8012 -c 1 raw1.sl raw2.ub
+if cmp -s raw1.ub raw2.ub
+then
+ echo "Conversion between unsigned bytes and signed long was successful"
+else
+ echo "Error converting between signed long and unsigned bytes"
+fi
+rm -f raw1.uw raw2.ub
+
+rm -f raw1.ub
+
+./sox $noise monkey.au -u -b monkey1.wav
+
+echo ""
+
+ext=8svx
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=aiff
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+# AU doesn't support unsigned so use signed
+ext=au
+./sox $noise monkey1.wav -s -b convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=avr
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=dat
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=hcom
+# HCOM has to be at specific sample rate.
+./sox $noise -r 5512 monkey1.wav nmonkey1.wav
+./sox $noise nmonkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s nmonkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext nmonkey1.wav monkey2.wav
+
+ext=maud
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=sf
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=smp
+./sox $noise monkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s monkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext monkey2.wav
+
+ext=voc
+./sox $noise -r 8000 monkey1.wav nmonkey1.wav
+./sox $noise nmonkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s nmonkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext nmonkey1.wav monkey2.wav
+
+ext=wve
+./sox $noise -r 8000 monkey1.wav nmonkey1.wav
+./sox $noise nmonkey1.wav convert.$ext
+./sox $noise convert.$ext -u -b monkey2.wav
+if cmp -s nmonkey1.wav monkey2.wav
+then
+ echo "Conversion between wav and $ext was successful"
+else
+ echo "Error converting between wav and $ext."
+fi
+rm -f convert.$ext nmonkey1.wav monkey2.wav
+
+exit
+
+
./sox $noise -r 8196 -u -b -c 1 ub2.raw -r 8196 ub2.voc
echo Comparing ub.raw to ub2.raw
cmp -l ub.raw ub2.raw
--- a/src/trim.c
+++ b/src/trim.c
@@ -11,7 +11,7 @@
* Sound Tools skeleton effect file.
*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
/* Time resolutin one millisecond */
@@ -38,10 +38,7 @@
/*
* Process options
*/
-int st_trim_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_trim_getopts(eff_t effp, int n, char **argv)
{
trim_t trim = (trim_t) effp->priv;
@@ -92,8 +89,7 @@
/*
* Start processing
*/
-int st_trim_start(effp)
-eff_t effp;
+int st_trim_start(eff_t effp)
{
trim_t trim = (trim_t) effp->priv;
@@ -133,11 +129,8 @@
* Place in buf[].
* Return number of samples read.
*/
-
-int st_trim_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_trim_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
int done;
int offset;
@@ -207,8 +200,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_trim_stop(effp)
-eff_t effp;
+int st_trim_stop(eff_t effp)
{
trim_t trim = (trim_t) effp->priv;
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -41,7 +41,7 @@
#include <stdio.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for TX16 file */
typedef struct txwstuff {
@@ -74,8 +74,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_txwstartread(ft)
- ft_t ft;
+int st_txwstartread(ft_t ft)
{
int c;
char filetype[7];
@@ -187,9 +186,7 @@
* Return number of samples read.
*/
-LONG st_txwread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_txwread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
txw_t sk = (txw_t) ft->priv;
int done = 0;
@@ -243,14 +240,12 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_txwstopread(ft)
-ft_t ft;
+int st_txwstopread(ft_t ft)
{
return(ST_SUCCESS);
}
-int st_txwstartwrite(ft)
-ft_t ft;
+int st_txwstartwrite(ft_t ft)
{
struct WaveHeader_ WH;
@@ -279,9 +274,7 @@
return(ST_SUCCESS);
}
-LONG st_txwwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_txwwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
int i;
unsigned int w1,w2;
@@ -304,8 +297,7 @@
return(len);
}
-int st_txwstopwrite(ft)
-ft_t ft;
+int st_txwstopwrite(ft_t ft)
{
struct WaveHeader_ WH;
int AttackLength, LoopLength, i;
--- a/src/util.c
+++ b/src/util.c
@@ -7,7 +7,7 @@
* the consequences of using this software.
*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
#include <ctype.h>
#include <signal.h>
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -26,7 +26,7 @@
#include <math.h>
#include <stdlib.h>
-#include "st.h"
+#include "st_i.h"
/* Private data for Vibro effect */
typedef struct vibrostuff {
@@ -41,10 +41,7 @@
/*
* Process options
*/
-int st_vibro_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_vibro_getopts(eff_t effp, int n, char **argv)
{
vibro_t vibro = (vibro_t) effp->priv;
@@ -67,10 +64,7 @@
/* This was very painful. We need a sine library. */
/* SJB: this is somewhat different than st_sine() */
/* FIXME: move to misc.c */
-static void sine(buf, len, depth)
-short *buf;
-int len;
-float depth;
+static void sine(short *buf, int len, float depth)
{
int i;
int scale = depth * 128;
@@ -86,8 +80,7 @@
/*
* Prepare processing.
*/
-int st_vibro_start(effp)
-eff_t effp;
+int st_vibro_start(eff_t effp)
{
vibro_t vibro = (vibro_t) effp->priv;
@@ -109,10 +102,8 @@
* Return number of samples processed.
*/
-int st_vibro_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_vibro_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
vibro_t vibro = (vibro_t) effp->priv;
register int counter, tablen;
@@ -139,8 +130,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_vibro_stop(effp)
-eff_t effp;
+int st_vibro_stop(eff_t effp)
{
/* nothing to do */
return (ST_SUCCESS);
--- a/src/voc.c
+++ b/src/voc.c
@@ -138,7 +138,7 @@
------------------------------------------------------------------------*/
-#include "st.h"
+#include "st_i.h"
#include <string.h>
/* Private data for VOC file */
@@ -171,8 +171,7 @@
static void blockstart(ft_t);
static void blockstop(ft_t);
-int st_vocstartread(ft)
-ft_t ft;
+int st_vocstartread(ft_t ft)
{
char header[20];
vs_t v = (vs_t) ft->priv;
@@ -229,9 +228,7 @@
return(ST_SUCCESS);
}
-LONG st_vocread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_vocread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
vs_t v = (vs_t) ft->priv;
int done = 0;
@@ -284,8 +281,7 @@
}
/* nothing to do */
-int st_vocstopread(ft)
-ft_t ft;
+int st_vocstopread(ft_t ft)
{
return(ST_SUCCESS);
}
@@ -301,8 +297,7 @@
* which will work with the oldest software (eg. an 8-bit mono sample
* will be able to be played with a really old SB VOC player.)
*/
-int st_vocstartwrite(ft)
-ft_t ft;
+int st_vocstartwrite(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
@@ -337,9 +332,7 @@
return(ST_SUCCESS);
}
-LONG st_vocwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_vocwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
vs_t v = (vs_t) ft->priv;
unsigned char uc;
@@ -366,8 +359,7 @@
return done;
}
-int st_vocstopwrite(ft)
-ft_t ft;
+int st_vocstopwrite(ft_t ft)
{
blockstop(ft);
return(ST_SUCCESS);
@@ -376,9 +368,7 @@
/* Voc-file handlers */
/* Read next block header, save info, leave position at start of data */
-static int
-getblock(ft)
-ft_t ft;
+static int getblock(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
unsigned char uc, block;
@@ -565,8 +555,7 @@
}
/* Start an output block. */
-static void blockstart(ft)
-ft_t ft;
+static void blockstart(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
@@ -620,8 +609,7 @@
}
/* End the current data or silence block. */
-static void blockstop(ft)
-ft_t ft;
+static void blockstop(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
LONG datum;
@@ -646,4 +634,3 @@
st_writeb(ft, (int)datum); /* high byte of length */
}
}
-
--- a/src/vol.c
+++ b/src/vol.c
@@ -8,7 +8,7 @@
* Cannot handle rate change.
*/
-#include "st.h"
+#include "st_i.h"
#include <math.h> /* exp(), sqrt() */
#include <limits.h> /* LONG_MAX */
@@ -49,10 +49,7 @@
/*
* Process options: gain (float) type (amplitude, power, dB)
*/
-int st_vol_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
+int st_vol_getopts(eff_t effp, int n, char **argv)
{
vol_t vol = (vol_t) effp->priv;
vol->gain = ONE; /* default is no change */
@@ -110,8 +107,7 @@
/*
* Start processing
*/
-int st_vol_start(effp)
-eff_t effp;
+int st_vol_start(eff_t effp)
{
vol_t vol = (vol_t) effp->priv;
@@ -162,10 +158,8 @@
/*
* Process data.
*/
-int st_vol_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
+int st_vol_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+ st_size_t *isamp, st_size_t *osamp)
{
vol_t vol = (vol_t) effp->priv;
register VOL_FLOAT gain = vol->gain;
@@ -217,8 +211,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_vol_stop(effp)
-eff_t effp;
+int st_vol_stop(eff_t effp)
{
vol_t vol = (vol_t) effp->priv;
if (vol->limited)
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -22,7 +22,7 @@
#include <math.h>
#include <errno.h>
#include <string.h>
-#include "st.h"
+#include "st_i.h"
#include <ogg/ogg.h>
#include <vorbis/codec.h>
@@ -85,8 +85,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_vorbisstartread(ft)
-ft_t ft;
+int st_vorbisstartread(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_info *vi;
@@ -178,8 +177,7 @@
/* Refill the buffer with samples. Returns BUF_EOF if the end of the
vorbis data was reached while the buffer was being filled,
BUF_ERROR is something bad happens, and BUF_DATA otherwise */
-int refill_buffer (vb)
-vorbis_t vb;
+int refill_buffer (vorbis_t vb)
{
int num_read;
@@ -214,9 +212,7 @@
* Return number of samples read.
*/
-LONG st_vorbisread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_vorbisread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
vorbis_t vb = (vorbis_t) ft->priv;
int i;
@@ -250,8 +246,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_vorbisstopread(ft)
-ft_t ft;
+int st_vorbisstopread(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
@@ -275,9 +270,7 @@
/* Write out the header packets. Derived mostly from encode.c in
oggenc. Returns HEADER_ERROR if the header cannot be written and
HEADER_OK otherwise. */
-int write_vorbis_header(ft, ve)
-ft_t ft;
-vorbis_enc_t *ve;
+int write_vorbis_header(ft_t ft, vorbis_enc_t *ve)
{
ogg_packet header_main;
ogg_packet header_comments;
@@ -318,8 +311,7 @@
return HEADER_OK;
}
-int st_vorbisstartwrite(ft)
-ft_t ft;
+int st_vorbisstartwrite(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve;
@@ -351,9 +343,7 @@
return(ST_SUCCESS);
}
-LONG st_vorbiswrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_vorbiswrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve = vb->vorbis_enc_data;
@@ -400,8 +390,7 @@
return (ST_SUCCESS);
}
-int st_vorbisstopwrite(ft)
-ft_t ft;
+int st_vorbisstopwrite(ft_t ft)
{
vorbis_t vb = (vorbis_t) ft->priv;
vorbis_enc_t *ve = vb->vorbis_enc_data;
--- a/src/wav.c
+++ b/src/wav.c
@@ -67,7 +67,7 @@
#include <unistd.h> /* For SEEK_* defines if not found in stdio */
#endif
-#include "st.h"
+#include "st_i.h"
#include "wav.h"
#include "ima_rw.h"
#include "adpcm.h"
@@ -127,8 +127,7 @@
* ImaAdpcmReadBlock - Grab and decode complete block of samples
*
*/
-unsigned short ImaAdpcmReadBlock(ft)
-ft_t ft;
+unsigned short ImaAdpcmReadBlock(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int bytesRead;
@@ -168,8 +167,7 @@
* AdpcmReadBlock - Grab and decode complete block of samples
*
*/
-unsigned short AdpcmReadBlock(ft)
-ft_t ft;
+unsigned short AdpcmReadBlock(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int bytesRead;
@@ -204,8 +202,7 @@
/* Common ADPCM Write Function */
/****************************************************************************/
-static int xxxAdpcmWriteBlock(ft)
-ft_t ft;
+static int xxxAdpcmWriteBlock(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int chans, ct;
@@ -246,8 +243,7 @@
/****************************************************************************/
#ifdef HAVE_LIBGSM
/* create the gsm object, malloc buffer for 160*2 samples */
-int wavgsminit(ft)
-ft_t ft;
+int wavgsminit(ft_t ft)
{
int valueP=1;
wav_t wav = (wav_t) ft->priv;
@@ -274,8 +270,7 @@
}
/*destroy the gsm object and free the buffer */
-void wavgsmdestroy(ft)
-ft_t ft;
+void wavgsmdestroy(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
gsm_destroy(wav->gsmhandle);
@@ -282,9 +277,7 @@
free(wav->gsmsample);
}
-LONG wavgsmread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t wavgsmread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
wav_t wav = (wav_t) ft->priv;
int done=0;
@@ -328,9 +321,7 @@
return done;
}
-static int wavgsmflush(ft, pad)
-ft_t ft;
-int pad; /* normally 0, but 1 to pad last write to even datalen */
+static int wavgsmflush(ft_t ft, int pad)
{
gsm_byte frame[65];
wav_t wav = (wav_t) ft->priv;
@@ -364,9 +355,7 @@
return (ST_SUCCESS);
}
-LONG wavgsmwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t wavgsmwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
wav_t wav = (wav_t) ft->priv;
int done = 0;
@@ -389,8 +378,7 @@
}
-void wavgsmstopwrite(ft)
-ft_t ft;
+void wavgsmstopwrite(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
@@ -406,19 +394,6 @@
/* General Sox WAV file code */
/****************************************************************************/
-/* FIXME: Use common misc.c skip code
-
-moved to misc.c using st_seek(ft,len,SEEK_CUR) instead
-
-static void fSkip(FILE *fp, ULONG len)
-{
- while (len > 0 && !feof(fp))
- {
- getc(fp);
- len--;
- }
-}
-*/
static ULONG findChunk(ft_t ft, const char *Label)
{
char magic[5];
@@ -448,8 +423,7 @@
* size and encoding of samples,
* mono/stereo/quad.
*/
-int st_wavstartread(ft)
-ft_t ft;
+int st_wavstartread(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
char magic[5];
@@ -516,7 +490,7 @@
/* Default (-1) depends on sample size. Set that later on. */
if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_UNSIGNED &&
ft->info.encoding != ST_ENCODING_SIGN2)
- st_warn("User options overriding encoding read in .wav header");
+ st_report("User options overriding encoding read in .wav header");
/* Needed by rawread() functions */
rc = st_rawstartread(ft);
@@ -529,7 +503,7 @@
if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_IMA_ADPCM)
ft->info.encoding = ST_ENCODING_IMA_ADPCM;
else
- st_warn("User options overriding encoding read in .wav header");
+ st_report("User options overriding encoding read in .wav header");
break;
case WAVE_FORMAT_ADPCM:
@@ -536,7 +510,7 @@
if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ADPCM)
ft->info.encoding = ST_ENCODING_ADPCM;
else
- st_warn("User options overriding encoding read in .wav header");
+ st_report("User options overriding encoding read in .wav header");
break;
case WAVE_FORMAT_IEEE_FLOAT:
@@ -547,7 +521,7 @@
if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ALAW)
ft->info.encoding = ST_ENCODING_ALAW;
else
- st_warn("User options overriding encoding read in .wav header");
+ st_report("User options overriding encoding read in .wav header");
/* Needed by rawread() functions */
rc = st_rawstartread(ft);
@@ -560,7 +534,7 @@
if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ULAW)
ft->info.encoding = ST_ENCODING_ULAW;
else
- st_warn("User options overriding encoding read in .wav header");
+ st_report("User options overriding encoding read in .wav header");
/* Needed by rawread() functions */
rc = st_rawstartread(ft);
@@ -586,7 +560,7 @@
if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_GSM )
ft->info.encoding = ST_ENCODING_GSM;
else
- st_warn("User options overriding encoding read in .wav header");
+ st_report("User options overriding encoding read in .wav header");
break;
#else
st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in GSM6.10 format and no GSM support present, recompile sox with gsm library");
@@ -624,12 +598,12 @@
if (ft->info.channels == -1 || ft->info.channels == wChannels)
ft->info.channels = wChannels;
else
- st_warn("User options overriding channels read in .wav header");
+ st_report("User options overriding channels read in .wav header");
if (ft->info.rate == 0 || ft->info.rate == wSamplesPerSecond)
ft->info.rate = wSamplesPerSecond;
else
- st_warn("User options overriding rate read in .wav header");
+ st_report("User options overriding rate read in .wav header");
wav->iCoefs = NULL;
@@ -985,9 +959,7 @@
* Return number of samples read.
*/
-LONG st_wavread(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_wavread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
wav_t wav = (wav_t) ft->priv;
LONG done;
@@ -1081,8 +1053,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int st_wavstopread(ft)
-ft_t ft;
+int st_wavstopread(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int rc = ST_SUCCESS;
@@ -1110,8 +1081,7 @@
return rc;
}
-int st_wavstartwrite(ft)
-ft_t ft;
+int st_wavstartwrite(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
int rc;
@@ -1232,9 +1202,7 @@
*/
-static int wavwritehdr(ft, second_header)
-ft_t ft;
-int second_header;
+static int wavwritehdr(ft_t ft, int second_header)
{
wav_t wav = (wav_t) ft->priv;
@@ -1294,7 +1262,7 @@
ft->info.encoding != ST_ENCODING_ADPCM &&
ft->info.encoding != ST_ENCODING_IMA_ADPCM)
{
- st_warn("Do not support %s with 8-bit data. Forcing to unsigned",st_encodings_str[ft->info.encoding]);
+ st_warn("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;
}
break;
@@ -1302,7 +1270,7 @@
wBitsPerSample = 16;
if (ft->info.encoding != ST_ENCODING_SIGN2)
{
- st_warn("Do not support %s with 16-bit data. Forcing to Signed.",st_encodings_str[ft->info.encoding]);
+ st_warn("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;
}
break;
@@ -1310,13 +1278,13 @@
wBitsPerSample = 32;
if (ft->info.encoding != ST_ENCODING_SIGN2)
{
- st_warn("Do not support %s with 16-bit data. Forcing to Signed.",st_encodings_str[ft->info.encoding]);
+ st_warn("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;
}
break;
default:
- st_warn("Do not support %s in WAV files. Forcing to Signed Words.",st_sizes_str[ft->info.size]);
+ st_warn("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;
wBitsPerSample = 16;
@@ -1499,9 +1467,7 @@
return ST_SUCCESS;
}
-LONG st_wavwrite(ft, buf, len)
-ft_t ft;
-LONG *buf, len;
+st_ssize_t st_wavwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
wav_t wav = (wav_t) ft->priv;
LONG total_len = len;
@@ -1543,8 +1509,7 @@
}
}
-int st_wavstopwrite(ft)
-ft_t ft;
+int st_wavstopwrite(ft_t ft)
{
wav_t wav = (wav_t) ft->priv;
@@ -1594,9 +1559,7 @@
/*
* Return a string corresponding to the wave format type.
*/
-static char *
-wav_format_str(wFormatTag)
-unsigned wFormatTag;
+static char *wav_format_str(unsigned wFormatTag)
{
switch (wFormatTag)
{
@@ -1645,9 +1608,7 @@
}
}
-int st_wavseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_wavseek(ft_t ft, st_size_t offset)
{
wav_t wav = (wav_t) ft->priv;
--- a/src/wve.c
+++ b/src/wve.c
@@ -3,7 +3,7 @@
* Richard Caley (R.Caley@ed.ac.uk)
*/
-#include "st.h"
+#include "st_i.h"
#include "g72x.h"
#include <string.h>
#include <errno.h>
@@ -25,9 +25,7 @@
static void wvewriteheader(ft_t ft);
-int st_wveseek(ft,offset)
-ft_t ft;
-LONG offset;
+int st_wveseek(ft_t ft, st_size_t offset)
{
wve_t wve = (wve_t ) ft->priv;
@@ -34,8 +32,7 @@
return st_seek(ft,offset*ft->info.size + wve->dataStart,SEEK_SET);
}
-int st_wvestartread(ft)
-ft_t ft;
+int st_wvestartread(ft_t ft)
{
wve_t p = (wve_t ) ft->priv;
char magic[16];
@@ -103,8 +100,12 @@
ft->info.encoding = ST_ENCODING_ALAW;
ft->info.size = ST_SIZE_BYTE;
+ if (ft->info.rate != 0)
+ st_report("WVE must use 8000 sample rate. Overriding");
ft->info.rate = 8000;
+ if (ft->info.channels != -1 && ft->info.channels != 1)
+ st_report("WVE must only supports 1 channel. Overriding");
ft->info.channels = 1;
p->dataStart = ftell(ft->fp);
@@ -122,8 +123,7 @@
if it is not, the unspecified size remains in the header
(this is illegal). */
-int st_wvestartwrite(ft)
-ft_t ft;
+int st_wvestartwrite(ft_t ft)
{
wve_t p = (wve_t ) ft->priv;
int rc;
@@ -145,6 +145,12 @@
if (p->repeats == 0)
p->repeats = 1;
+ if (ft->info.rate != 0)
+ st_report("WVE must use 8000 sample rate. Overriding");
+
+ if (ft->info.channels != -1 && ft->info.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;
@@ -153,16 +159,12 @@
return ST_SUCCESS;
}
-LONG st_wveread(ft, buf, samp)
-ft_t ft;
-LONG *buf, samp;
+st_ssize_t st_wveread(ft_t ft, st_sample_t *buf, st_ssize_t samp)
{
return st_rawread(ft, buf, samp);
}
-LONG st_wvewrite(ft, buf, samp)
-ft_t ft;
-LONG *buf, samp;
+st_ssize_t st_wvewrite(ft_t ft, st_sample_t *buf, st_ssize_t samp)
{
wve_t p = (wve_t ) ft->priv;
p->length += samp * ft->info.size;
@@ -169,8 +171,7 @@
return st_rawwrite(ft, buf, samp);
}
-int st_wvestopwrite(ft)
-ft_t ft;
+int st_wvestopwrite(ft_t ft)
{
if (!ft->seekable)
{
@@ -189,8 +190,7 @@
return st_rawstopwrite(ft);
}
-static void wvewriteheader(ft)
-ft_t ft;
+static void wvewriteheader(ft_t ft)
{
char magic[16];
@@ -215,4 +215,3 @@
st_writew(ft, zero);
st_writew(ft, zero);
}
-