# HG changeset patch # User Mychaela Falconia # Date 1712516718 0 # Node ID b875c8edd54f26b7620536984c56816534e5269c # Parent d5bcfb378049b9076880edf9816303de9dbba8a4 ringing: generate North American ringing signal diff -r d5bcfb378049 -r b875c8edd54f .hgignore --- a/.hgignore Sun Apr 07 07:20:46 2024 +0000 +++ b/.hgignore Sun Apr 07 19:05:18 2024 +0000 @@ -8,3 +8,6 @@ ^dmw/gen-dmw-bin$ ^dmw/dmw-[au]law\. + +^ringing/genring$ +^ringing/ringing\. diff -r d5bcfb378049 -r b875c8edd54f ringing/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ringing/Makefile Sun Apr 07 19:05:18 2024 +0000 @@ -0,0 +1,21 @@ +CC= gcc +CFLAGS= -O2 +PROG= genring +FILES= ringing.robe ringing.ul ringing.al + +all: ${PROG} ${FILES} + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} -o $@ $@.c -lm + +ringing.robe: ${PROG} + ./${PROG} $@ + +ringing.ul: ringing.robe + pcm16-to-ulaw ringing.robe $@ + +ringing.al: ringing.robe + pcm16-to-alaw ringing.robe $@ + +clean: + rm -f *.o ${PROG} *.robe *.ul *.al diff -r d5bcfb378049 -r b875c8edd54f ringing/genring.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ringing/genring.c Sun Apr 07 19:05:18 2024 +0000 @@ -0,0 +1,48 @@ +/* + * This program computes the waveform for the North American precise tone plan + * ringing signal, specifically the 2 s long ON phase, and writes it into a + * "robe" PCM16 file. + */ + +#include +#include +#include +#include + +#define FREQ_LOW (M_PI * 440.0 / 4000.0) +#define FREQ_HIGH (M_PI * 480.0 / 4000.0) + +#define AMPL_PEAK 2552.329f /* -19 dBm0 */ + +#define TOTAL_SAMPLES 16000 + +main(argc, argv) + char **argv; +{ + FILE *outf; + float angle_low, angle_high; + unsigned nsamp; + int sample; + unsigned sample_out; + + if (argc != 2) { + fprintf(stderr, "usage: %s outfile\n", argv[0]); + exit(1); + } + outf = fopen(argv[1], "w"); + if (!outf) { + perror(argv[1]); + exit(1); + } + angle_low = 0; + angle_high = 0; + for (nsamp = 0; nsamp < TOTAL_SAMPLES; nsamp++) { + sample = (sinf(angle_low) + sinf(angle_high)) * AMPL_PEAK; + sample_out = sample & 0xFFFF; + putc(sample_out >> 8, outf); + putc(sample_out & 0xFF, outf); + angle_low += FREQ_LOW; + angle_high += FREQ_HIGH; + } + exit(0); +}