It works standalone now

This commit is contained in:
dcp1990 2005-06-14 02:40:07 +00:00
parent 01eeffa5e0
commit af469ee545
15 changed files with 464 additions and 108 deletions

25
lib/libpvf/Makefile Normal file
View file

@ -0,0 +1,25 @@
# cnd Makefile
# (C)2005, Dan Ponte
# $Amigan: phoned/lib/libpvf/Makefile,v 1.1 2005/06/14 02:40:07 dcp1990 Exp $
include ../../global.mk
# basic stuff. we append for a reason.
CPPFLAGS=-I../include
CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS}
LDFLAGS=
# keep these up to date.
MAINBIN=libpvf.a
SRCS=au.c fft.c lib.c linear.c multitech.c rockwell.c usr.c voc.c wav.c zyxel-o56k.c zyxel.c
OBJS=au.o fft.o lib.o linear.o multitech.o rockwell.o usr.o voc.o wav.o zyxel-o56k.o zyxel.o
all: .depend ${MAINBIN}
# I know, I know, but it's good.
.depend: ${SRCS} ${OHDRS}
mkdep ${CPPFLAGS} -MM -p ${SRCS}
${MAINBIN}: ${OBJS}
ar rc ${MAINBIN} ${OBJS}
ranlib ${MAINBIN}
# for this app
%.o: %.c
${CC} ${CFLAGS} -c ${.SOURCE}
# end ours
clean:
rm -f *.o ${MAINBIN} .depend *~ *.core ${CLEANFILES}

View file

@ -6,9 +6,9 @@
* $Id: au.c,v 1.6 2001/05/14 09:52:30 marcs Exp $
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include <string.h>
#include "pvf.h"
typedef long Word; /* must be 32 bits */
typedef struct
@ -245,7 +245,7 @@ unsigned char alaw2ulaw (unsigned char alawbyte)
}
static Word read_word (FILE *in)
static Word read_word (FILE* in)
{
Word w;
@ -363,11 +363,11 @@ int pvftoau (FILE *fd_in, FILE *fd_out, pvf_header *header_in,
break;
default:
fprintf(stderr, "%s: unsupported sound file format requested",
program_name);
return(ERROR);
"libpvf");
return(-1);
}
return(OK);
return(1);
}
int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
@ -387,8 +387,8 @@ int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
if (hdr.magic != SND_MAGIC)
{
fprintf(stderr, "%s: illegal magic number for an .au file",
program_name);
return(ERROR);
"libpvf");
return(0);
}
#ifdef PRINT_INFO
@ -397,7 +397,7 @@ int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
if ((hdr.dataFormat >= 0) && (hdr.dataFormat < (sizeof(sound_format) /
sizeof(sound_format[0]))))
printf("%s: Data format: %s\n", program_name,
printf("%s: Data format: %s\n", "libpvf",
sound_format[hdr.dataFormat]);
else
printf("%s: Data format unknown, code=%ld\n", prgoram_name,
@ -412,17 +412,17 @@ int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
if (hdr.channelCount != 1)
{
fprintf(stderr, "%s: number of channels (%ld) is not 1\n",
program_name, hdr.channelCount);
return(ERROR);
"libpvf", hdr.channelCount);
return(0);
}
header_out->speed = hdr.samplingRate;
if (write_pvf_header(fd_out, header_out) != OK)
if (write_pvf_header(fd_out, header_out) != 1)
{
fprintf(stderr, "%s: could not write pvf header\n",
program_name);
return(ERROR);
"libpvf");
return(0);
};
for (i = ftell(fd_in); i < hdr.dataLocation; i++)
@ -430,8 +430,8 @@ int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
if (getc(fd_in) == EOF)
{
fprintf(stderr, "%s: unexpected end of file\n",
program_name);
return(ERROR);
"libpvf");
return(0);
}
switch (hdr.dataFormat)
@ -478,11 +478,11 @@ int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
break;
default:
fprintf(stderr, "%s: unsupported or illegal sound encoding\n",
program_name);
return(ERROR);
"libpvf");
return(0);
}
return(OK);
return(1);
}
int pvftoulaw(FILE *fd_in, FILE *fd_out, pvf_header *header_in)
@ -492,8 +492,8 @@ int pvftoulaw(FILE *fd_in, FILE *fd_out, pvf_header *header_in)
if (header_in->speed != 8000)
{
fprintf(stderr, "%s: sample speed (%d) must be 8000\n",
program_name, header_in->speed);
return(ERROR);
"libpvf", header_in->speed);
return(0);
};
while (1)
@ -504,7 +504,7 @@ int pvftoulaw(FILE *fd_in, FILE *fd_out, pvf_header *header_in)
putc(linear2ulaw(sample), fd_out);
}
return(OK);
return(1);
}
int ulawtopvf(FILE *fd_in, FILE *fd_out, pvf_header *header_out)
@ -514,14 +514,14 @@ int ulawtopvf(FILE *fd_in, FILE *fd_out, pvf_header *header_out)
if (header_out->speed != 8000)
{
fprintf(stderr, "%s: sample speed (%d) must be 8000\n",
program_name, header_out->speed);
return(ERROR);
"libpvf", header_out->speed);
return(0);
};
while ((sample = getc(fd_in)) != EOF)
header_out->write_pvf_data(fd_out, ulaw2linear(sample) << 8);
return(OK);
return(1);
}
int pvftoalaw(FILE *fd_in, FILE *fd_out, pvf_header *header_in)
@ -531,8 +531,8 @@ int pvftoalaw(FILE *fd_in, FILE *fd_out, pvf_header *header_in)
if (header_in->speed != 8000)
{
fprintf(stderr, "%s: sample speed (%d) must be 8000\n",
program_name, header_in->speed);
return(ERROR);
"libpvf", header_in->speed);
return(0);
};
while (1)
@ -543,7 +543,7 @@ int pvftoalaw(FILE *fd_in, FILE *fd_out, pvf_header *header_in)
putc(ulaw2alaw(linear2ulaw(sample)), fd_out);
}
return(OK);
return(1);
}
int alawtopvf(FILE *fd_in, FILE *fd_out, pvf_header *header_out)
@ -553,12 +553,12 @@ int alawtopvf(FILE *fd_in, FILE *fd_out, pvf_header *header_out)
if (header_out->speed != 8000)
{
fprintf(stderr, "%s: sample speed (%d) must be 8000\n",
program_name, header_out->speed);
return(ERROR);
"libpvf", header_out->speed);
return(0);
};
while ((sample = getc(fd_in)) != EOF)
header_out->write_pvf_data(fd_out, ulaw2linear(alaw2ulaw(sample)) << 8);
return(OK);
return(1);
}

View file

@ -6,9 +6,10 @@
* $Id: fft.c,v 1.5 1999/03/16 09:59:19 marcs Exp $
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "pvf.h"
static void fft (float *real, float *imag, int n)
{
@ -99,8 +100,8 @@ int pvffft (FILE *fd_in, pvf_header *header_in, int skip, int sample_size,
if (((i & 0x01) != 0) && (i != 1))
{
fprintf(stderr, "%s: sample size (%d) must be a power of 2\n",
program_name, sample_size);
return(ERROR);
"libpvf", sample_size);
return(0);
}
}
@ -110,8 +111,8 @@ int pvffft (FILE *fd_in, pvf_header *header_in, int skip, int sample_size,
if ((real == NULL) || (imag == NULL))
{
fprintf(stderr, "%s: not enough memory\n", program_name);
return(ERROR);
fprintf(stderr, "%s: not enough memory\n", "libpvf");
return(0);
}
for(i = 0; i < sample_size; i++)
@ -144,8 +145,8 @@ int pvffft (FILE *fd_in, pvf_header *header_in, int skip, int sample_size,
*/
fprintf(stderr, "%s: not enough samples available\n",
program_name);
return(ERROR);
"libpvf");
return(0);
}
}
@ -185,7 +186,7 @@ int pvffft (FILE *fd_in, pvf_header *header_in, int skip, int sample_size,
if (sum < threshold)
kill(vgetty_pid, SIGUSR2);
return(OK);
return(1);
}
if (display)
@ -196,9 +197,9 @@ int pvffft (FILE *fd_in, pvf_header *header_in, int skip, int sample_size,
header_in->speed, sqrt(real[i] * real[i] +
imag[i] * imag[i]) / max);
return(OK);
return(1);
};
printf("%s: FFT level is %g\n", program_name, sum);
return(OK);
printf("%s: FFT level is %g\n", "libpvf", sum);
return(1);
}

18
lib/libpvf/header.h Normal file
View file

@ -0,0 +1,18 @@
/*
* voice_header.h
*
* Defines the header for raw modem data.
*
* $Id: header.h,v 1.4 1998/09/09 21:06:35 gert Exp $
*
*/
typedef struct
{
char magic[4];
char voice_modem_type[16];
short compression;
short speed;
char bits;
char reserved[7];
} rmd_header;

View file

@ -7,8 +7,10 @@
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include "pvf.h"
rmd_header init_rmd_header = {"RMD1", "", 0x0000, 0, 0, {0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00}};
state_t init_state = {0x0000, 0};
@ -89,18 +91,18 @@ int read_rmd_header(FILE *fd_in, rmd_header *header_in)
if (fread(header_in, sizeof(rmd_header), 1, fd_in) != 1)
{
fprintf(stderr, "%s: Could not read rmd header\n", program_name);
return(FAIL);
fprintf(stderr, "%s: Could not read rmd header\n", "libpvf");
return(-1);
};
if (strncmp(header_in->magic, "RMD1", 4) != 0)
{
fprintf(stderr, "%s: No rmd (raw modem data) header found\n",
program_name);
return(FAIL);
"libpvf");
return(-1);
};
return(OK);
return(1);
}
int write_rmd_header(FILE *fd_out, rmd_header *header_out)
@ -108,11 +110,11 @@ int write_rmd_header(FILE *fd_out, rmd_header *header_out)
if (fwrite(header_out, sizeof(rmd_header), 1, fd_out) != 1)
{
fprintf(stderr, "%s: Could not write rmd header\n", program_name);
return(FAIL);
fprintf(stderr, "%s: Could not write rmd header\n", "libpvf");
return(-1);
};
return(OK);
return(1);
}
static int read_pvf_data_8_ascii(FILE *fd_in)
@ -265,8 +267,8 @@ int read_pvf_header(FILE *fd_in, pvf_header *header_in)
if (fread(&buffer, 5, 1, fd_in) != 1)
{
fprintf(stderr, "%s: Could not read pvf header\n", program_name);
return(FAIL);
fprintf(stderr, "%s: Could not read pvf header\n", "libpvf");
return(-1);
};
if (strncmp(buffer, "PVF1\n", 5) == 0)
@ -276,8 +278,8 @@ int read_pvf_header(FILE *fd_in, pvf_header *header_in)
else
{
fprintf(stderr, "%s: No pvf (portable voice format) header found\n",
program_name);
return(FAIL);
"libpvf");
return(-1);
};
for (i = 0; i < VOICE_BUF_LEN; i++)
@ -285,8 +287,8 @@ int read_pvf_header(FILE *fd_in, pvf_header *header_in)
if (fread(&buffer[i], 1, 1, fd_in) != 1)
{
fprintf(stderr, "%s: Could not read pvf header\n", program_name);
return(FAIL);
fprintf(stderr, "%s: Could not read pvf header\n", "libpvf");
return(-1);
};
if (buffer[i] == '\n')
@ -301,23 +303,23 @@ int read_pvf_header(FILE *fd_in, pvf_header *header_in)
if ((header_in->channels < 1) || (32 < header_in->channels))
{
fprintf(stderr, "%s: Invalid number of channels (%d)\n",
program_name, header_in->channels);
return(FAIL);
"libpvf", header_in->channels);
return(-1);
};
if ((header_in->speed < 0) || (50000 < header_in->speed))
{
fprintf(stderr, "%s: Invalid sample speed (%d)\n", program_name,
fprintf(stderr, "%s: Invalid sample speed (%d)\n", "libpvf",
header_in->speed);
return(FAIL);
return(-1);
};
if ((header_in->nbits != 8) && (header_in->nbits != 16) &&
(header_in->nbits != 32))
{
fprintf(stderr, "%s: Invalid number of bits (%d) per sample\n",
program_name, header_in->nbits);
return(FAIL);
"libpvf", header_in->nbits);
return(-1);
};
if (header_in->ascii)
@ -336,8 +338,8 @@ int read_pvf_header(FILE *fd_in, pvf_header *header_in)
break;
default:
fprintf(stderr, "%s: Illegal bit size for pvf input\n",
program_name);
return(FAIL);
"libpvf");
return(-1);
};
}
@ -357,13 +359,13 @@ int read_pvf_header(FILE *fd_in, pvf_header *header_in)
break;
default:
fprintf(stderr, "%s: Illegal bit size for pvf input\n",
program_name);
return(FAIL);
"libpvf");
return(-1);
};
};
return(OK);
return(1);
}
int write_pvf_header(FILE *fd_out, pvf_header *header_out)
@ -388,8 +390,8 @@ int write_pvf_header(FILE *fd_out, pvf_header *header_out)
break;
default:
fprintf(stderr, "%s: Illegal bit size for pvf output\n",
program_name);
return(FAIL);
"libpvf");
return(-1);
};
}
@ -411,19 +413,19 @@ int write_pvf_header(FILE *fd_out, pvf_header *header_out)
break;
default:
fprintf(stderr, "%s: Illegal bit size for pvf output\n",
program_name);
return(FAIL);
"libpvf");
return(-1);
};
};
if (fwrite(&buffer, strlen(buffer), 1, fd_out) != 1)
{
fprintf(stderr, "%s: Could not write pvf header\n", program_name);
return(FAIL);
fprintf(stderr, "%s: Could not write pvf header\n", "libpvf");
return(-1);
};
return(OK);
return(1);
}
pvf_header init_pvf_header = {FALSE, 1, 8000, 32, &read_pvf_data_32,

View file

@ -6,9 +6,9 @@
* $Id: linear.c,v 1.5 1999/03/16 09:59:20 marcs Exp $
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include <string.h>
#include "pvf.h"
int pvftolin (FILE *fd_in, FILE *fd_out, pvf_header *header_in, int is_signed,
int bits16, int intel)
{

View file

@ -8,9 +8,8 @@
* $Id: multitech.c,v 1.3 1998/09/09 21:07:02 gert Exp $
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include "pvf.h"
/***********************************************************
Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The
Netherlands.
@ -57,7 +56,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
** - Changed some of the variable names to be more meaningful.
*/
#include "../include/adpcm.h"
#include "adpcm.h"
#include <stdio.h> /*DBG*/
#ifndef __STDC__

146
lib/libpvf/pvf.h Normal file
View file

@ -0,0 +1,146 @@
/*
* pvf.h
*
* Contains the constants and function prototypes for the pvf tools
*
* $Id: pvf.h,v 1.7 2001/05/14 09:52:29 marcs Exp $
*
*/
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include "bitsizes.h"
#include "header.h"
#include "wav.h"
# define M_PI 3.14159265358979323846
#define VOICE_BUF_LEN (256)
#define FALSE 0
#define TRUE 1
#define OK 1
#define FAIL -1
#define ERROR 0
#define program_name "libpvf"
/*
* Constants
*/
/*
* Blocksize for reading voice files into memory
*/
#define BLOCK_SIZE 0x10000
/*
* Decimal point shift for fixed-point arithmetic
*/
#define SHIFT 12
#define ONE (1 << SHIFT)
/*
* Structure for handling pvf files
*/
typedef struct
{
int ascii;
int channels;
int speed;
int nbits;
int (*read_pvf_data) (FILE *fd_in);
void (*write_pvf_data) (FILE *fd_out, int data);
} pvf_header;
/*
* Structure for handling bit read and write operations
*/
typedef struct
{
int data;
int nleft;
} state_t;
extern rmd_header init_rmd_header;
extern pvf_header init_pvf_header;
extern state_t init_state;
extern int bitmask[17];
/*
* Functions
*/
extern unsigned char linear2ulaw (int sample);
extern int ulaw2linear (unsigned char ulawbyte);
extern int read_rmd_header (FILE *fd_in, rmd_header *header_in);
extern int write_rmd_header (FILE *fd_out, rmd_header *header_out);
extern int read_pvf_header (FILE *fd_in, pvf_header *header_in);
extern int write_pvf_header (FILE *fd_out, pvf_header *header_out);
extern int read_bits (FILE *fd_in, state_t *state, int nbits);
extern void write_bits (FILE *fd_out, state_t *state, int nbits, int data);
extern int read_bits_reverse (FILE *fd_in, state_t *state, int nbits);
extern void write_bits_reverse (FILE *fd_out, state_t *state, int nbits,
int data);
extern int pvftorockwell (FILE *fd_in, FILE *fd_out, int nbits,
pvf_header *header_in);
extern int rockwelltopvf (FILE *fd_in, FILE *fd_out, int nbits,
pvf_header *header_out);
extern int pvftorockwellpcm (FILE *fd_in, FILE *fd_out, int nbits,
pvf_header *header_in);
extern int rockwellpcmtopvf (FILE *fd_in, FILE *fd_out, int nbits,
pvf_header *header_out);
extern int pvftozyxel (FILE *fd_in, FILE *fd_out, int nbits,
pvf_header *header_in);
extern int zyxeltopvf (FILE *fd_in, FILE *fd_out, int nbits,
pvf_header *header_out);
extern int pvftozo56k (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
extern int zo56ktopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
extern int pvftousr (FILE *fd_in, FILE *fd_out, int compression,
pvf_header *header_in);
extern int usrtopvf (FILE *fd_in, FILE *fd_out, int compression,
pvf_header *header_out);
extern int pvftoimaadpcm (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
extern int imaadpcmtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
extern int pvftovoc (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
extern int voctopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
extern int pvftolin (FILE *fd_in, FILE *fd_out, pvf_header *header_in,
int is_signed, int bits16, int intel);
extern int lintopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out,
int is_signed, int bits16, int intel);
extern int pvftoulaw (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
extern int ulawtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
extern int pvftoalaw (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
extern int alawtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
#define pvftobasic pvftoulaw
#define basictopvf ulawtopvf
#define SND_FORMAT_MULAW_8 1
#define SND_FORMAT_LINEAR_8 2
#define SND_FORMAT_LINEAR_16 3
#define SND_FORMAT_ALAW_8 27
extern int pvftoau (FILE *fd_in, FILE *fd_out, pvf_header *header_in,
int dataFormat);
extern int autopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
extern int pvftowav (FILE *fd_in, FILE *fd_out, pvf_header *header_in,
int wav_bits);
extern int wavtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
extern int pvffft (FILE *fd_in, pvf_header *header_in, int skip,
int sample_size, double threshold, int vgetty_pid, int display);

View file

@ -59,9 +59,8 @@
*/
#define RV_HONOUR_SILENCE_CODEWORDS
#include "../include/voice.h"
#include <stdio.h>
#include "pvf.h"
/*
PJ:
A first attempt to implement basically all that the original

View file

@ -7,20 +7,21 @@
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include "pvf.h"
/* Forward defs of the format-specific routines
*/
static int pvftousrgsm (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
/* static int pvftousrgsm (FILE *fd_in, FILE *fd_out, pvf_header *header_in); */
static int pvftousradpcm (FILE *fd_in, FILE *fd_out, pvf_header *header_in);
static int usrgsmtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
/* static int usrgsmtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out); */
static int usradpcmtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out);
int pvftousr(FILE *fd_in, FILE *fd_out, int compression,
pvf_header *header_in) {
switch (compression) {
case 1:
return (pvftousrgsm(fd_in, fd_out, header_in));
/*case 1:
return (pvftousrgsm(fd_in, fd_out, header_in)); */
case 4:
return (pvftousradpcm(fd_in, fd_out, header_in));
default:
@ -31,15 +32,15 @@ int pvftousr(FILE *fd_in, FILE *fd_out, int compression,
int usrtopvf (FILE *fd_in, FILE *fd_out, int compression,
pvf_header *header_out) {
switch (compression) {
case 1:
return (usrgsmtopvf(fd_in, fd_out, header_out));
/* case 1:
return (usrgsmtopvf(fd_in, fd_out, header_out)); */
case 4:
return (usradpcmtopvf(fd_in, fd_out, header_out));
default:
return -1;
}
}
#if 0
/*****************
** GSM SECTION **
*****************/
@ -188,7 +189,7 @@ static int usrgsmtopvf (FILE *fd_in, FILE *fd_out, pvf_header *header_out)
}
return(OK);
}
#endif
/*******************

View file

@ -6,9 +6,9 @@
* $Id: voc.c,v 1.4 1998/09/09 21:07:05 gert Exp $
*
*/
#include "../include/voice.h"
#include <string.h>
#include <stdio.h>
#include "pvf.h"
static char voc_hdr[32] =
{
'C','r','e','a','t','i','v','e',' ',

View file

@ -9,9 +9,9 @@
*
* $Id: wav.c,v 1.6 2000/07/22 09:57:46 marcs Exp $
*/
#include "../include/voice.h"
#include <string.h>
#include <stdio.h>
#include "pvf.h"
char *sizes[] =
{
"NONSENSE!",

163
lib/libpvf/wav.h Normal file
View file

@ -0,0 +1,163 @@
/*
* wav.h
*
* This file includes the definitions for the wav file format.
*
* $Id: wav.h,v 1.4 1998/09/09 21:06:40 gert Exp $
*
*/
#define WAVE_FORMAT_UNKNOWN (0x0000)
#define WAVE_FORMAT_PCM (0x0001)
#define WAVE_FORMAT_ADPCM (0x0002)
#define WAVE_FORMAT_ALAW (0x0006)
#define WAVE_FORMAT_MULAW (0x0007)
#define WAVE_FORMAT_OKI_ADPCM (0x0010)
#define WAVE_FORMAT_DIGISTD (0x0015)
#define WAVE_FORMAT_DIGIFIX (0x0016)
#define IBM_FORMAT_MULAW (0x0101)
#define IBM_FORMAT_ALAW (0x0102)
#define IBM_FORMAT_ADPCM (0x0103)
/*
* Handler structure for each format.
*/
typedef struct format
{
char **names; /* file type names */
int flags; /* details about file type */
int (*startread)();
int (*read)();
int (*stopread)();
int (*startwrite)();
int (*write)();
int (*stopwrite)();
} format_t;
extern format_t formats[];
/* Signal parameters */
struct signalinfo
{
long rate; /* sampling rate */
int size; /* word length of data */
int style; /* format of sample numbers */
int channels; /* number of sound channels */
};
/* Loop parameters */
struct loopinfo
{
int start; /* first sample */
int length; /* length */
int count; /* number of repeats, 0=forever */
int type; /* 0=no, 1=forward, 2=forward/back */
};
/* Instrument parameters */
/* vague attempt at generic information for sampler-specific info */
struct 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 */
};
#define MIDI_UNITY 60 /* MIDI note number to play sample at unity */
/* Loop modes */
#define LOOP_NONE 0
#define LOOP_8 1 /* 8 loops: don't know ?? */
#define LOOP_SUSTAIN_DECAY 2 /* AIFF style: one sustain & one decay loop */
/*
* Format information for input and output files.
*/
#define PRIVSIZE 100
#define NLOOPS 8
struct soundstream
{
struct signalinfo info; /* signal specifications */
struct instrinfo instr; /* instrument specification */
struct loopinfo loops[NLOOPS]; /* Looping specification */
char swap; /* do byte- or word-swap */
char seekable; /* can seek on this file */
char *filename; /* file name */
char *filetype; /* type of file */
char *comment; /* comment string */
FILE *fp; /* File stream pointer */
format_t *h; /* format struct for this file */
double priv[PRIVSIZE/8]; /* format's private data area */
};
extern struct soundstream informat, outformat;
typedef struct soundstream *ft_t;
/* flags field */
#define FILE_STEREO 1 /* does file format support stereo? */
#define FILE_LOOPS 2 /* does file format support loops? */
#define FILE_INSTR 4 /* does file format support instrument specificications? */
/* Size field */
#define BYTE 1
#define WORD 2
#define LONG 4
#define FLOAT 5
#define DOUBLE 6
#define IEEE 7 /* IEEE 80-bit floats. Is it necessary? */
/* Style field */
#define UNSIGNED 1 /* unsigned linear: Sound Blaster */
#define SIGN2 2 /* signed linear 2's comp: Mac */
#define ULAW 3 /* U-law signed logs: US telephony, SPARC */
#define ALAW 4 /* A-law signed logs: non-US telephony */
extern char *sizes[], *styles[];
/*
* Handler structure for each effect.
*/
typedef struct
{
char *name; /* effect name */
int flags; /* this and that */
int (*getopts)(); /* process arguments */
int (*start)(); /* start off effect */
int (*flow)(); /* do a buffer */
int (*drain)(); /* drain out at end */
int (*stop)(); /* finish up effect */
} effect_t;
extern effect_t effects[];
#define EFF_CHAN 1 /* Effect can mix channels up/down */
#define EFF_RATE 2 /* Effect can alter data rate */
#define EFF_MCHAN 4 /* Effect can handle multi-channel */
#define EFF_REPORT 8 /* Effect does nothing */
struct effect
{
char *name; /* effect name */
struct signalinfo ininfo; /* input signal specifications */
struct loopinfo loops[8]; /* input loops specifications */
struct instrinfo instr; /* input instrument specifications */
struct signalinfo outinfo; /* output signal specifications */
effect_t *h; /* effects driver */
long *obuf; /* output buffer */
long odone, olen; /* consumed, total length */
double priv[PRIVSIZE]; /* private area for effect */
};
typedef struct effect *eff_t;

View file

@ -19,8 +19,9 @@
* $Id: zyxel-o56k.c,v 1.1 2000/07/22 10:01:01 marcs Exp $
*
*/
#include "../include/voice.h"
#include <string.h>
#include <stdio.h>
#include "pvf.h"
#define BL 16380

View file

@ -11,8 +11,9 @@
* $Id: zyxel.c,v 1.4 1998/09/09 21:07:06 gert Exp $
*
*/
#include "../include/voice.h"
#include <stdio.h>
#include <string.h>
#include "pvf.h"
static int Mx[3][8] =
{