Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/time_scale.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 * time_scale.h - Time scaling for linear speech data | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2004 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: time_scale.h,v 1.20 2009/02/10 13:06:47 steveu Exp $ | |
26 */ | |
27 | |
28 #if !defined(_SPANDSP_TIME_SCALE_H_) | |
29 #define _SPANDSP_TIME_SCALE_H_ | |
30 | |
31 /*! \page time_scale_page Time scaling speech | |
32 \section time_scale_page_sec_1 What does it do? | |
33 The time scaling module allows speech files to be played back at a | |
34 different speed from the speed at which they were recorded. If this | |
35 were done by simply speeding up or slowing down replay, the pitch of | |
36 the voice would change, and sound very odd. This module keeps the pitch | |
37 of the voice at its original level. | |
38 | |
39 The speed of the voice may be altered over a wide range. However, the practical | |
40 useful rates are between about half normal speed and twice normal speed. | |
41 | |
42 \section time_scale_page_sec_2 How does it work? | |
43 The time scaling module is based on the Pointer Interval Controlled | |
44 OverLap and Add (PICOLA) method, developed by Morita Naotaka. | |
45 Mikio Ikeda has an excellent web page on this subject at | |
46 http://keizai.yokkaichi-u.ac.jp/~ikeda/research/picola.html | |
47 There is also working code there. This implementation uses | |
48 exactly the same algorithms, but the code is a complete rewrite. | |
49 Mikio's code batch processes files. This version works incrementally | |
50 on streams, and allows multiple streams to be processed concurrently. | |
51 | |
52 \section time_scale_page_sec_3 How do I used it? | |
53 The output buffer must be big enough to hold the maximum number of samples which | |
54 could result from the data in the input buffer, which is: | |
55 | |
56 input_len*playout_rate + sample_rate/TIME_SCALE_MIN_PITCH + 1 | |
57 */ | |
58 | |
59 /*! Audio time scaling descriptor. */ | |
60 typedef struct time_scale_state_s time_scale_state_t; | |
61 | |
62 #if defined(__cplusplus) | |
63 extern "C" | |
64 { | |
65 #endif | |
66 | |
67 /*! Initialise a time scale context. This must be called before the first | |
68 use of the context, to initialise its contents. | |
69 \brief Initialise a time scale context. | |
70 \param s The time scale context. | |
71 \param sample_rate The sample rate of the signal. | |
72 \param playout_rate The ratio between the output speed and the input speed. | |
73 \return A pointer to the context, or NULL if there was a problem. */ | |
74 SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sample_rate, float playout_rate); | |
75 | |
76 /*! \brief Release a time scale context. | |
77 \param s The time scale context. | |
78 \return 0 for OK, else -1. */ | |
79 SPAN_DECLARE(int) time_scale_release(time_scale_state_t *s); | |
80 | |
81 /*! \brief Free a time scale context. | |
82 \param s The time scale context. | |
83 \return 0 for OK, else -1. */ | |
84 SPAN_DECLARE(int) time_scale_free(time_scale_state_t *s); | |
85 | |
86 /*! Change the time scale rate. | |
87 \brief Change the time scale rate. | |
88 \param s The time scale context. | |
89 \param playout_rate The ratio between the output speed and the input speed. | |
90 \return 0 if changed OK, else -1. */ | |
91 SPAN_DECLARE(int) time_scale_rate(time_scale_state_t *s, float playout_rate); | |
92 | |
93 /*! Find the maximum possible samples which could result from scaling the specified | |
94 number of input samples, at the current playback rate. | |
95 \brief Find the maximum possible output samples. | |
96 \param s The time scale context. | |
97 \param input_len The number of input samples. | |
98 \return The maximum possible output samples. */ | |
99 SPAN_DECLARE(int) time_scale_max_output_len(time_scale_state_t *s, int input_len); | |
100 | |
101 /*! Time scale a chunk of audio samples. | |
102 \brief Time scale a chunk of audio samples. | |
103 \param s The time scale context. | |
104 \param out The output audio sample buffer. This must be large enough to accept | |
105 the longest possible result from processing the input data. See the | |
106 algorithm documentation for how the longest possible result may be calculated. | |
107 \param in The input audio sample buffer. | |
108 \param len The number of input samples. | |
109 \return The number of output samples. | |
110 */ | |
111 SPAN_DECLARE(int) time_scale(time_scale_state_t *s, int16_t out[], int16_t in[], int len); | |
112 | |
113 #if defined(__cplusplus) | |
114 } | |
115 #endif | |
116 | |
117 #endif | |
118 /*- End of file ------------------------------------------------------------*/ |