comparison spandsp-0.0.6pre17/src/spandsp/silence_gen.h @ 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 * silence_gen.c - A silence generator, for inserting timed silences.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2006 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 Lesser General Public License version 2.1,
14 * as 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 Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * $Id: silence_gen.h,v 1.19 2009/09/04 14:38:47 steveu Exp $
26 */
27
28 #if !defined(_SPANDSP_SILENCE_GEN_H_)
29 #define _SPANDSP_SILENCE_GEN_H_
30
31 typedef struct silence_gen_state_s silence_gen_state_t;
32
33 #if defined(__cplusplus)
34 extern "C"
35 {
36 #endif
37
38 /*! Generate a block of silent audio samples.
39 \brief Generate a block of silent audio samples.
40 \param s The silence generator context.
41 \param amp The audio sample buffer.
42 \param max_len The number of samples to be generated.
43 \return The number of samples actually generated. This will be zero when
44 there is nothing to send.
45 */
46 SPAN_DECLARE_NONSTD(int) silence_gen(silence_gen_state_t *s, int16_t *amp, int max_len);
47
48 /*! Set a silence generator context to output continuous silence.
49 \brief Set a silence generator context to output continuous silence.
50 \param s The silence generator context.
51 */
52 SPAN_DECLARE(void) silence_gen_always(silence_gen_state_t *s);
53
54 /*! Set a silence generator context to output a specified period of silence.
55 \brief Set a silence generator context to output a specified period of silence.
56 \param s The silence generator context.
57 \param silent_samples The number of samples to be generated.
58 */
59 SPAN_DECLARE(void) silence_gen_set(silence_gen_state_t *s, int silent_samples);
60
61 /*! Alter the period of a silence generator context by a specified amount.
62 \brief Alter the period of a silence generator context by a specified amount.
63 \param s The silence generator context.
64 \param silent_samples The number of samples to change the setting by. A positive number
65 increases the duration. A negative number reduces it. The duration
66 is prevented from going negative.
67 */
68 SPAN_DECLARE(void) silence_gen_alter(silence_gen_state_t *s, int silent_samples);
69
70 /*! Find how long a silence generator context has to run.
71 \brief Find how long a silence generator context has to run.
72 \param s The silence generator context.
73 \return The number of samples remaining.
74 */
75 SPAN_DECLARE(int) silence_gen_remainder(silence_gen_state_t *s);
76
77 /*! Find the total silence generated to date by a silence generator context.
78 \brief Find the total silence generated to date.
79 \param s The silence generator context.
80 \return The number of samples generated.
81 */
82 SPAN_DECLARE(int) silence_gen_generated(silence_gen_state_t *s);
83
84 /*! Change the status reporting function associated with a silence generator context.
85 \brief Change the status reporting function associated with a silence generator context.
86 \param s The silence generator context.
87 \param handler The callback routine used to report status changes.
88 \param user_data An opaque pointer. */
89 SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_tx_status_func_t handler, void *user_data);
90
91 /*! Initialise a timed silence generator context.
92 \brief Initialise a timed silence generator context.
93 \param s The silence generator context.
94 \param silent_samples The initial number of samples to set the silence to.
95 \return A pointer to the silence generator context.
96 */
97 SPAN_DECLARE(silence_gen_state_t *) silence_gen_init(silence_gen_state_t *s, int silent_samples);
98
99 SPAN_DECLARE(int) silence_gen_release(silence_gen_state_t *s);
100
101 SPAN_DECLARE(int) silence_gen_free(silence_gen_state_t *s);
102
103 /* The following dummy routines, to absorb data, don't really have a proper home,
104 so they have been put here. */
105
106 /*! A dummy routine to use as a receive callback, when we aren't really
107 trying to process what is received. It just absorbs and ignores the
108 data.
109 \brief Dummy receive callback.
110 \param user_data The context.
111 \param amp The signal.buffer
112 \param len The length of the signal buffer
113 \return 0.
114 */
115 SPAN_DECLARE_NONSTD(int) span_dummy_rx(void *user_data, const int16_t amp[], int len);
116
117 /*! A dummy routine to use as a signal modifier callback, when we aren't
118 really trying to process the signal. It just returns without affecting
119 anything.
120 \brief Dummy signal modifier callback.
121 \param user_data The context.
122 \param amp The signal.buffer
123 \param len The length of the signal buffer
124 \return 0.
125 */
126 SPAN_DECLARE(int) span_dummy_mod(void *user_data, int16_t amp[], int len);
127
128 /*! A dummy routine to use as a receive fillin callback, when we aren't really
129 trying to process what is received. It just absorbs and ignores the
130 request.
131 \brief Dummy receive fillin callback.
132 \param user_data The context.
133 \param len The length of the signal buffer
134 \return 0.
135 */
136 SPAN_DECLARE_NONSTD(int) span_dummy_rx_fillin(void *user_data, int len);
137
138 #if defined(__cplusplus)
139 }
140 #endif
141
142 #endif
143 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.