Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/tests/r2_mf_tx_tests.c @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * r2_mf_tx_tests.c - Test the Bell MF generator. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2003 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU General Public License version 2, as | |
| 14 * published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU General Public License | |
| 22 * along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: r2_mf_tx_tests.c,v 1.16 2009/05/30 15:23:14 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 /*! \page r2_mf_tx_tests_page R2 MF generation tests | |
| 31 \section r2_mf_tx_tests_page_sec_1 What does it do? | |
| 32 ???. | |
| 33 | |
| 34 \section r2_mf_tx_tests_page_sec_2 How does it work? | |
| 35 ???. | |
| 36 */ | |
| 37 | |
| 38 /* Enable the following definition to enable direct probing into the FAX structures */ | |
| 39 //#define WITH_SPANDSP_INTERNALS | |
| 40 | |
| 41 #if defined(HAVE_CONFIG_H) | |
| 42 #include "config.h" | |
| 43 #endif | |
| 44 | |
| 45 #include <stdlib.h> | |
| 46 #include <stdio.h> | |
| 47 #include <fcntl.h> | |
| 48 #include <string.h> | |
| 49 #include <time.h> | |
| 50 #include <sndfile.h> | |
| 51 | |
| 52 //#if defined(WITH_SPANDSP_INTERNALS) | |
| 53 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES | |
| 54 //#endif | |
| 55 | |
| 56 #include "spandsp.h" | |
| 57 #include "spandsp-sim.h" | |
| 58 | |
| 59 #define OUTPUT_FILE_NAME "r2_mf.wav" | |
| 60 | |
| 61 int main(int argc, char *argv[]) | |
| 62 { | |
| 63 r2_mf_tx_state_t gen; | |
| 64 int16_t amp[1000]; | |
| 65 int len; | |
| 66 SNDFILE *outhandle; | |
| 67 int outframes; | |
| 68 int digit; | |
| 69 const char *digits = "0123456789BCDEF"; | |
| 70 | |
| 71 if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL) | |
| 72 { | |
| 73 fprintf(stderr, " Cannot open audio file '%s'\n", OUTPUT_FILE_NAME); | |
| 74 exit(2); | |
| 75 } | |
| 76 | |
| 77 r2_mf_tx_init(&gen, FALSE); | |
| 78 for (digit = 0; digits[digit]; digit++) | |
| 79 { | |
| 80 r2_mf_tx_put(&gen, digits[digit]); | |
| 81 len = r2_mf_tx(&gen, amp, 1000); | |
| 82 printf("Generated %d samples of %c\n", len, digits[digit]); | |
| 83 if (len > 0) | |
| 84 outframes = sf_writef_short(outhandle, amp, len); | |
| 85 r2_mf_tx_put(&gen, 0); | |
| 86 len = r2_mf_tx(&gen, amp, 1000); | |
| 87 printf("Generated %d samples\n", len); | |
| 88 if (len > 0) | |
| 89 outframes = sf_writef_short(outhandle, amp, len); | |
| 90 } | |
| 91 | |
| 92 r2_mf_tx_init(&gen, TRUE); | |
| 93 for (digit = 0; digits[digit]; digit++) | |
| 94 { | |
| 95 r2_mf_tx_put(&gen, digits[digit]); | |
| 96 len = r2_mf_tx(&gen, amp, 1000); | |
| 97 printf("Generated %d samples of %c\n", len, digits[digit]); | |
| 98 if (len > 0) | |
| 99 outframes = sf_writef_short(outhandle, amp, len); | |
| 100 r2_mf_tx_put(&gen, 0); | |
| 101 len = r2_mf_tx(&gen, amp, 1000); | |
| 102 printf("Generated %d samples\n", len); | |
| 103 if (len > 0) | |
| 104 outframes = sf_writef_short(outhandle, amp, len); | |
| 105 } | |
| 106 | |
| 107 if (sf_close(outhandle) != 0) | |
| 108 { | |
| 109 fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME); | |
| 110 exit (2); | |
| 111 } | |
| 112 | |
| 113 return 0; | |
| 114 } | |
| 115 /*- End of function --------------------------------------------------------*/ | |
| 116 /*- End of file ------------------------------------------------------------*/ |
