diff --git a/channels/Makefile b/channels/Makefile index c31d3df280..d1402a2518 100755 --- a/channels/Makefile +++ b/channels/Makefile @@ -19,6 +19,8 @@ CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so) CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API") +CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DTORMENTA_PRI") +TORPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri") CFLAGS+=#-DVOFRDUMPER @@ -31,16 +33,24 @@ all: $(CHANNEL_LIBS) clean: rm -f *.so *.o + rm -f busy.h ringtone.h gentone %.so : %.o $(CC) -shared -Xlinker -x -o $@ $< -#libiax.a: libiax.o -# rm -f libiax.a -# $(AR) cr libiax.a libiax.o +gentone: gentone.c + $(CC) -o gentone gentone.c -lm + +busy.h: gentone + ./gentone busy 480 620 + +ringtone.h: gentone + ./gentone ringtone 440 480 + +chan_oss.o: chan_oss.c busy.h ringtone.h chan_tor.so: chan_tor.o - $(CC) -shared -Xlinker -x -o $@ $< -lzap -ltonezone + $(CC) -shared -Xlinker -x -o $@ $< $(TORPRI) -lzap -ltonezone #chan_modem.so : chan_modem.o # $(CC) -rdynamic -shared -Xlinker -x -o $@ $< diff --git a/channels/gentone.c b/channels/gentone.c new file mode 100755 index 0000000000..00f5af1794 --- /dev/null +++ b/channels/gentone.c @@ -0,0 +1,95 @@ +/* Generate a header file for a particular + single or double frequency */ + +#include +#include +#include +#include +#include +#define CLIP 32635 +#define BIAS 0x84 +static float loudness=16384.0; + +static int calc_samples(int freq) +{ + int x, samples; + /* Calculate the number of samples at 8000hz sampling + we need to have this wave form */ + samples = 8000; + /* Take out common 2's up to six times */ + for (x=0;x<6;x++) + if (!(freq % 2)) { + freq /= 2; + samples /= 2; + } + /* Take out common 5's (up to three times */ + for (x=0;x<3;x++) + if (!(freq % 5)) { + freq /= 5; + samples /=5; + } + /* No more common factors. */ + return samples; +} + +int main(int argc, char *argv[]) +{ + FILE *f; + int freq1, freq2; + float wlen1, wlen2; + float val; + int x, samples1, samples2, samples=0; + char fn[256]; + if (argc < 3) { + fprintf(stderr, "Usage: gensound [freq2]\n"); + exit(1); + } + freq1 = atoi(argv[2]); + if (argc > 3) + freq2 = atoi(argv[3]); + else + freq2 = 0; + wlen1 = 8000.0/(float)freq1; + samples1 = calc_samples(freq1); + printf("Wavelength 1 (in samples): %10.5f\n", wlen1); + printf("Minimum samples (1): %d (%f.3 wavelengths)\n", samples1, samples1 / wlen1); + if (freq2) { + wlen2 = 8000.0/(float)freq2; + samples2 = calc_samples(freq2); + printf("Wavelength 1 (in samples): %10.5f\n", wlen2); + printf("Minimum samples (1): %d (%f.3 wavelengths)\n", samples2, samples2 / wlen2); + } + samples = samples1; + if (freq2) { + while(samples % samples2) + samples += samples1; + } + printf("Need %d samples\n", samples); + snprintf(fn, sizeof(fn), "%s.h", argv[1]); + if ((f = fopen(fn, "w"))) { + if (freq2) + fprintf(f, "/* %s: Generated from frequencies %d and %d \n" + " by gensound. %d samples */\n", fn, freq1, freq2, samples); + else + fprintf(f, "/* %s: Generated from frequency %d\n" + " by gensound. %d samples */\n", fn, freq1, samples); + fprintf(f, "static short %s[%d] = {\n\t", argv[1], samples); + for (x=0;x