]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
change namespace on bell202 to fsk in preparation for generalizing the code for more...
authorMichael Jerris <mike@jerris.com>
Sun, 3 Jun 2007 17:51:20 +0000 (17:51 +0000)
committerMichael Jerris <mike@jerris.com>
Sun, 3 Jun 2007 17:51:20 +0000 (17:51 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@204 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/msvc/openzap.vcproj
libs/openzap/src/dsp/bell202.h [deleted file]
libs/openzap/src/dsp/fsk.c [moved from libs/openzap/src/dsp/bell202.c with 86% similarity]
libs/openzap/src/dsp/fsk.h [new file with mode: 0644]
libs/openzap/src/dsp/readme.txt

index 60f41cdf403f32cbb5c711855711a599bff44cf3..84fe2d134b4a08e6a2aa46e0f085a1dcbf4ae56a 100644 (file)
                                Name="Header Files"\r
                                >\r
                                <File\r
-                                       RelativePath="..\src\dsp\bell202.h"\r
+                                       RelativePath="..\src\dsp\fsk.h"\r
                                        >\r
                                </File>\r
                                <File\r
                                Name="Source Files"\r
                                >\r
                                <File\r
-                                       RelativePath="..\src\dsp\bell202.c"\r
+                                       RelativePath="..\src\dsp\fsk.c"\r
                                        >\r
                                </File>\r
                                <File\r
diff --git a/libs/openzap/src/dsp/bell202.h b/libs/openzap/src/dsp/bell202.h
deleted file mode 100644 (file)
index 9ab47a9..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-
-/*
- *     bell202.h
- *
- *     Copyright (c) 2005 Robert Krten.  All Rights Reserved.
- *
- *     Redistribution and use in source and binary forms, with or without
- *     modification, are permitted provided that the following conditions
- *     are met:
- *
- *     1. Redistributions of source code must retain the above copyright
- *        notice, this list of conditions and the following disclaimer.
- *     2. Redistributions in binary form must reproduce the above copyright
- *        notice, this list of conditions and the following disclaimer in the
- *        documentation and/or other materials provided with the distribution.
- *
- *     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
- *     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- *     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- *     ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- *     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- *     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- *     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- *     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- *     SUCH DAMAGE.
- *
- *     This module contains the manifest constants and declarations for
- *     the Bell-202 1200 baud FSK modem.
- *
- *     2005 03 20      R. Krten                created
-*/
-
-#ifndef        __BELL202_H__
-#define        __BELL202_H__
-
-typedef void (*bytehandler_func_t) (void *, int);
-typedef void (*bithandler_func_t) (void *, int);
-
-typedef struct dsp_bell202_attr_s
-{
-       int                                     sample_rate;                                    // sample rate in HZ
-       bithandler_func_t       bithandler;                                             // bit handler
-       void                            *bithandler_arg;                                // arbitrary ID passed to bithandler as first argument
-       bytehandler_func_t      bytehandler;                                    // byte handler
-       void                            *bytehandler_arg;                               // arbitrary ID passed to bytehandler as first argument
-}      dsp_bell202_attr_t;
-
-typedef struct
-{
-       dsp_bell202_attr_t      attr;                                                   // attributes structure
-       double                          *correlates[4];                                 // one for each of sin/cos for mark/space
-       int                                     corrsize;                                               // correlate size (also number of samples in ring buffer)
-       double                          *buffer;                                                // sample ring buffer
-       int                                     ringstart;                                              // ring buffer start offset
-       double                          cellpos;                                                // bit cell position
-       double                          celladj;                                                // bit cell adjustment for each sample
-       int                                     previous_bit;                                   // previous bit (for detecting a transition to sync-up cell position)
-       int                                     current_bit;                                    // current bit
-       int                                     downsampling_count;                             // number of samples to skip
-       int                                     current_downsample;                             // current skip count
-}      dsp_bell202_handle_t;
-
-/*
- *     Function prototypes
- *
- *     General calling order is:
- *             a) create the attributes structure (dsp_bell202_attr_init)
- *             b) initialize fields in the attributes structure (dsp_bell202_attr_set_*)
- *             c) create a Bell-202 handle (dsp_bell202_create)
- *             d) feed samples through the handler (dsp_bell202_sample)
-*/
-
-void                                   dsp_bell202_attr_init(dsp_bell202_attr_t *attributes);
-
-bithandler_func_t              dsp_bell202_attr_get_bithandler(dsp_bell202_attr_t *attributes, void **bithandler_arg);
-void                                   dsp_bell202_attr_set_bithandler(dsp_bell202_attr_t *attributes, bithandler_func_t bithandler, void *bithandler_arg);
-bytehandler_func_t             dsp_bell202_attr_get_bytehandler(dsp_bell202_attr_t *attributes, void **bytehandler_arg);
-void                                   dsp_bell202_attr_set_bytehandler(dsp_bell202_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg);
-int                                            dsp_bell202_attr_get_samplerate(dsp_bell202_attr_t *attributes);
-int                                            dsp_bell202_attr_set_samplerate(dsp_bell202_attr_t *attributes, int samplerate);
-
-dsp_bell202_handle_t * dsp_bell202_create(dsp_bell202_attr_t *attributes);
-void                                   dsp_bell202_destroy(dsp_bell202_handle_t **handle);
-
-void                                   dsp_bell202_sample(dsp_bell202_handle_t *handle, double normalized_sample);
-
-#endif // __BELL202_H__
-
similarity index 86%
rename from libs/openzap/src/dsp/bell202.c
rename to libs/openzap/src/dsp/fsk.c
index cd1633febf3a995a5648411ebc35c70d8395dc97..e2d0360b77e84a545e75172e3f140e80d1ccca94 100644 (file)
 #define        BELL202_SPACE                   2200
 #define        BELL202_BAUD                    1200
 
+#define V23_MARK                               1300
+#define V23_SPACE                              2100
+#define V23_BAUD                               1200
+
 /*
- *     dsp_bell202_attr_init
+ *     dsp_fsk_attr_init
  *
  *     Initializes the attributes structure; this must be done before the
  *     attributes structure is used.
 */
 
-void dsp_bell202_attr_init (dsp_bell202_attr_t *attr)
+void dsp_fsk_attr_init (dsp_fsk_attr_t *attr)
 {
        memset(attr, 0, sizeof(*attr));
 }
 
 /*
- *     dsp_bell202_attr_get_bithandler
- *     dsp_bell202_attr_set_bithandler
- *     dsp_bell202_attr_get_bytehandler
- *     dsp_bell202_attr_set_bytehandler
- *     dsp_bell202_attr_getsamplerate
- *     dsp_bell202_attr_setsamplerate
+ *     dsp_fsk_attr_get_bithandler
+ *     dsp_fsk_attr_set_bithandler
+ *     dsp_fsk_attr_get_bytehandler
+ *     dsp_fsk_attr_set_bytehandler
+ *     dsp_fsk_attr_getsamplerate
+ *     dsp_fsk_attr_setsamplerate
  *
  *     These functions get and set their respective elements from the
  *     attributes structure.  If an error code is returned, it is just
  *     zero == ok, -1 == fail.
 */
 
-bithandler_func_t dsp_bell202_attr_get_bithandler(dsp_bell202_attr_t *attr, void **bithandler_arg)
+bithandler_func_t dsp_fsk_attr_get_bithandler(dsp_fsk_attr_t *attr, void **bithandler_arg)
 {
        *bithandler_arg = attr->bithandler_arg;
        return attr->bithandler;
 }
 
-void dsp_bell202_attr_set_bithandler(dsp_bell202_attr_t *attr, bithandler_func_t bithandler, void *bithandler_arg)
+void dsp_fsk_attr_set_bithandler(dsp_fsk_attr_t *attr, bithandler_func_t bithandler, void *bithandler_arg)
 {
        attr->bithandler = bithandler;
        attr->bithandler_arg = bithandler_arg;
 }
 
-bytehandler_func_t dsp_bell202_attr_get_bytehandler(dsp_bell202_attr_t *attr, void **bytehandler_arg)
+bytehandler_func_t dsp_fsk_attr_get_bytehandler(dsp_fsk_attr_t *attr, void **bytehandler_arg)
 {
        *bytehandler_arg = attr->bytehandler_arg;
        return attr->bytehandler;
 }
 
-void dsp_bell202_attr_set_bytehandler(dsp_bell202_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg)
+void dsp_fsk_attr_set_bytehandler(dsp_fsk_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg)
 {
        attr->bytehandler = bytehandler;
        attr->bytehandler_arg = bytehandler_arg;
 }
 
-int dsp_bell202_attr_get_samplerate (dsp_bell202_attr_t *attr)
+int dsp_fsk_attr_get_samplerate (dsp_fsk_attr_t *attr)
 {
        return attr->sample_rate;
 }
 
-int dsp_bell202_attr_set_samplerate (dsp_bell202_attr_t *attr, int samplerate)
+int dsp_fsk_attr_set_samplerate (dsp_fsk_attr_t *attr, int samplerate)
 {
        if (samplerate <= 0) {
                return -1;
@@ -115,7 +119,7 @@ int dsp_bell202_attr_set_samplerate (dsp_bell202_attr_t *attr, int samplerate)
 }
 
 /*
- *     dsp_bell202_create
+ *     dsp_fsk_create
  *
  *     Creates a handle for subsequent use.  The handle is created to contain
  *     a context data structure for use by the sample handler function.  The
@@ -125,11 +129,11 @@ int dsp_bell202_attr_set_samplerate (dsp_bell202_attr_t *attr, int samplerate)
  *     Once created, the handle can be used until it is destroyed.
 */
 
-dsp_bell202_handle_t *dsp_bell202_create(dsp_bell202_attr_t *attr)
+dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr)
 {
        int                                             i;
        double                                  phi_mark, phi_space;
-       dsp_bell202_handle_t    *handle;
+       dsp_fsk_handle_t        *handle;
 
        handle = malloc(sizeof(*handle));
        if (!handle) {
@@ -157,7 +161,7 @@ dsp_bell202_handle_t *dsp_bell202_create(dsp_bell202_attr_t *attr)
                handle->correlates[i] = malloc(sizeof(double) * handle->corrsize);
                if (handle->correlates[i] == NULL) {
                        /* some failed, back out memory allocations */
-                       dsp_bell202_destroy(&handle);
+                       dsp_fsk_destroy(&handle);
                        return NULL;
                }
        }
@@ -176,7 +180,7 @@ dsp_bell202_handle_t *dsp_bell202_create(dsp_bell202_attr_t *attr)
        /* initialize the ring buffer */
        handle->buffer = malloc(sizeof(double) * handle->corrsize);
        if (!handle->buffer) {                          /* failed; back out memory allocations */
-               dsp_bell202_destroy(&handle);
+               dsp_fsk_destroy(&handle);
                return NULL;
        }
        memset(handle->buffer, 0, sizeof(double) * handle->corrsize);
@@ -195,7 +199,7 @@ dsp_bell202_handle_t *dsp_bell202_create(dsp_bell202_attr_t *attr)
                dsp_uart_attr_set_bytehandler(&uart_attr, handle->attr.bytehandler, handle->attr.bytehandler_arg);
                uart_handle = dsp_uart_create(&uart_attr);
                if (uart_handle == NULL) {
-                       dsp_bell202_destroy(&handle);
+                       dsp_fsk_destroy(&handle);
                        return NULL;
                }
                handle->attr.bithandler = dsp_uart_bit_handler;
@@ -206,13 +210,13 @@ dsp_bell202_handle_t *dsp_bell202_create(dsp_bell202_attr_t *attr)
 }
 
 /*
- *     dsp_bell202_destroy
+ *     dsp_fsk_destroy
  *
  *     Destroys a handle, releasing any associated memory.  Sets handle pointer to NULL 
  *     so A destroyed handle can not be used for anything after the destroy.
 */
 
-void dsp_bell202_destroy(dsp_bell202_handle_t **handle)
+void dsp_fsk_destroy(dsp_fsk_handle_t **handle)
 {
        int             i;
 
@@ -242,7 +246,7 @@ void dsp_bell202_destroy(dsp_bell202_handle_t **handle)
 }
 
 /*
- *     dsp_bell202_sample
+ *     dsp_fsk_sample
  *
  *     This is the main processing entry point.  The function accepts a normalized
  *     sample (i.e., one whose range is between -1 and +1).  The function performs
@@ -254,7 +258,7 @@ void dsp_bell202_destroy(dsp_bell202_handle_t **handle)
 */
 
 void
-dsp_bell202_sample (dsp_bell202_handle_t *handle, double normalized_sample)
+dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
 {
        double  val;
        double  factors[4];
diff --git a/libs/openzap/src/dsp/fsk.h b/libs/openzap/src/dsp/fsk.h
new file mode 100644 (file)
index 0000000..dfb6af3
--- /dev/null
@@ -0,0 +1,90 @@
+
+/*
+ *     bell202.h
+ *
+ *     Copyright (c) 2005 Robert Krten.  All Rights Reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *     1. Redistributions of source code must retain the above copyright
+ *        notice, this list of conditions and the following disclaimer.
+ *     2. Redistributions in binary form must reproduce the above copyright
+ *        notice, this list of conditions and the following disclaimer in the
+ *        documentation and/or other materials provided with the distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
+ *     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *     ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
+ *     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ *     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ *     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ *     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ *     SUCH DAMAGE.
+ *
+ *     This module contains the manifest constants and declarations for
+ *     the Bell-202 1200 baud FSK modem.
+ *
+ *     2005 03 20      R. Krten                created
+*/
+
+#ifndef        __BELL202_H__
+#define        __BELL202_H__
+
+typedef void (*bytehandler_func_t) (void *, int);
+typedef void (*bithandler_func_t) (void *, int);
+
+typedef struct dsp_fsk_attr_s
+{
+       int                                     sample_rate;                                    /* sample rate in HZ */
+       bithandler_func_t       bithandler;                                             /* bit handler */
+       void                            *bithandler_arg;                                /* arbitrary ID passed to bithandler as first argument */
+       bytehandler_func_t      bytehandler;                                    /* byte handler */
+       void                            *bytehandler_arg;                               /* arbitrary ID passed to bytehandler as first argument */
+}      dsp_fsk_attr_t;
+
+typedef struct
+{
+       dsp_fsk_attr_t  attr;                                                   /* attributes structure */
+       double                          *correlates[4];                                 /* one for each of sin/cos for mark/space */
+       int                                     corrsize;                                               /* correlate size (also number of samples in ring buffer) */
+       double                          *buffer;                                                /* sample ring buffer */
+       int                                     ringstart;                                              /* ring buffer start offset */
+       double                          cellpos;                                                /* bit cell position */
+       double                          celladj;                                                /* bit cell adjustment for each sample */
+       int                                     previous_bit;                                   /* previous bit (for detecting a transition to sync-up cell position) */
+       int                                     current_bit;                                    /* current bit */
+       int                                     downsampling_count;                             /* number of samples to skip */
+       int                                     current_downsample;                             /* current skip count */
+}      dsp_fsk_handle_t;
+
+/*
+ *     Function prototypes
+ *
+ *     General calling order is:
+ *             a) create the attributes structure (dsp_fsk_attr_init)
+ *             b) initialize fields in the attributes structure (dsp_fsk_attr_set_*)
+ *             c) create a Bell-202 handle (dsp_fsk_create)
+ *             d) feed samples through the handler (dsp_fsk_sample)
+*/
+
+void                                   dsp_fsk_attr_init(dsp_fsk_attr_t *attributes);
+
+bithandler_func_t              dsp_fsk_attr_get_bithandler(dsp_fsk_attr_t *attributes, void **bithandler_arg);
+void                                   dsp_fsk_attr_set_bithandler(dsp_fsk_attr_t *attributes, bithandler_func_t bithandler, void *bithandler_arg);
+bytehandler_func_t             dsp_fsk_attr_get_bytehandler(dsp_fsk_attr_t *attributes, void **bytehandler_arg);
+void                                   dsp_fsk_attr_set_bytehandler(dsp_fsk_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg);
+int                                            dsp_fsk_attr_get_samplerate(dsp_fsk_attr_t *attributes);
+int                                            dsp_fsk_attr_set_samplerate(dsp_fsk_attr_t *attributes, int samplerate);
+
+dsp_fsk_handle_t *     dsp_fsk_create(dsp_fsk_attr_t *attributes);
+void                                   dsp_fsk_destroy(dsp_fsk_handle_t **handle);
+
+void                                   dsp_fsk_sample(dsp_fsk_handle_t *handle, double normalized_sample);
+
+#endif // __BELL202_H__
+
index 6283a4345e8d3425315bcb2b7aaa844e3eec7004..6a71f9bf10798fcf9fbc864512cda20794d7bdb3 100644 (file)
@@ -2,29 +2,29 @@ I have only tested the library with samples at 8kHz.  It *should* work with arbi
 \r
 The first thing you need to do is initialize a context structure:\r
 \r
-       dsp_bell202_attr_t              fsk1200_attr;                           // attributes structure for FSK 1200 baud modem\r
-       dsp_bell202_handle_t    *fsk1200_handle;                        // context structure for FSK 1200 baud modem\r
+       dsp_fsk_attr_t          fsk1200_attr;                           // attributes structure for FSK 1200 baud modem\r
+       dsp_fsk_handle_t        *fsk1200_handle;                        // context structure for FSK 1200 baud modem\r
 \r
        // initialize:\r
-       dsp_bell202_attr_init (&fsk1200_attr);                          // clear attributes structure\r
-       dsp_bell202_attr_set_samplerate (&fsk1200_attr, optr);  // set sample rate\r
-       dsp_bell202_attr_set_bytehandler (&fsk1200_attr, clid_byte_handler, ch);        // bind byte handler\r
+       dsp_fsk_attr_init (&fsk1200_attr);                              // clear attributes structure\r
+       dsp_fsk_attr_set_samplerate (&fsk1200_attr, optr);      // set sample rate\r
+       dsp_fsk_attr_set_bytehandler (&fsk1200_attr, clid_byte_handler, ch);    // bind byte handler\r
 \r
        // create context:\r
-       fsk1200_handle = dsp_bell202_create (&fsk1200_attr);\r
+       fsk1200_handle = dsp_fsk_create (&fsk1200_attr);\r
 \r
        // error check:\r
        if (fsk1200_handle == NULL) {\r
-               fprintf (stderr, "%s:  can't dsp_bell202_create, errno %d (%s)\n", progname, errno, strerror (errno));\r
+               fprintf (stderr, "%s:  can't dsp_fsk_create, errno %d (%s)\n", progname, errno, strerror (errno));\r
                exit (EXIT_FAILURE);\r
        }\r
 \r
 If you are decoding multiple channels, you will need multiple context structures; one per channel.\r
-The attributes ("dsp_bell202_attr_t") do not have to be persistent, but the handle does.\r
-There's even a "dsp_bell202_destroy()" function call to remove the context structure; I don't believe I've ever used it, my stuff hangs around forever.\r
+The attributes ("dsp_fsk_attr_t") do not have to be persistent, but the handle does.\r
+There's even a "dsp_fsk_destroy()" function call to remove the context structure; I don't believe I've ever used it, my stuff hangs around forever.\r
 \r
 Then, you need to feed samples into the software modem:\r
-       dsp_bell202_sample (fsk1200_handle, (double) sample / 32767.);\r
+       dsp_fsk_sample (fsk1200_handle, (double) sample / 32767.);\r
 \r
 It assumes the samples are between -1 and 1 as a double.\r
 \r