MythTV
0.27pre
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Groups
Pages
libs
libmythsoundtouch
TDStretch.h
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
16
// Last changed : $Date$
17
// File revision : $Revision$
18
//
19
// $Id$
20
//
22
//
23
// License :
24
//
25
// SoundTouch audio processing library
26
// Copyright (c) Olli Parviainen
27
//
28
// This library is free software; you can redistribute it and/or
29
// modify it under the terms of the GNU Lesser General Public
30
// License as published by the Free Software Foundation; either
31
// version 2.1 of the License, or (at your option) any later version.
32
//
33
// This library is distributed in the hope that it will be useful,
34
// but WITHOUT ANY WARRANTY; without even the implied warranty of
35
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36
// Lesser General Public License for more details.
37
//
38
// You should have received a copy of the GNU Lesser General Public
39
// License along with this library; if not, write to the Free Software
40
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41
//
43
44
#ifndef TDStretch_H
45
#define TDStretch_H
46
47
#include "
STTypes.h
"
48
#include "
RateTransposer.h
"
49
#include "
FIFOSamplePipe.h
"
50
51
#ifdef MULTICHANNEL
52
#define USE_MULTI_MMX
53
#endif
54
55
namespace
soundtouch
56
{
57
58
// Default values for sound processing parameters:
59
68
#define DEFAULT_SEQUENCE_MS 82
69
82
#define DEFAULT_SEEKWINDOW_MS 14
83
92
#define DEFAULT_OVERLAP_MS 12
93
94
97
class
TDStretch
:
public
FIFOProcessor
98
{
99
protected
:
100
uint
channels
;
101
uint
sampleReq
;
102
float
tempo
;
103
104
SAMPLETYPE
*
pMidBuffer
;
105
SAMPLETYPE
*
pRefMidBuffer
;
106
SAMPLETYPE
*
pRefMidBufferUnaligned
;
107
uint
midBufferLength
;
108
uint
overlapLength
;
109
uint
overlapDividerBits
;
110
uint
slopingDivider
;
111
uint
seekLength
;
112
uint
seekWindowLength
;
113
uint
maxOffset
;
114
float
nominalSkip
;
115
float
skipFract
;
116
FIFOSampleBuffer
outputBuffer
;
117
FIFOSampleBuffer
inputBuffer
;
118
BOOL
bQuickseek
;
119
BOOL
bMidBufferDirty
;
120
121
uint
sampleRate
;
122
uint
sequenceMs
;
123
uint
seekWindowMs
;
124
uint
overlapMs
;
125
126
void
acceptNewOverlapLength
(
uint
newOverlapLength);
127
128
virtual
void
clearCrossCorrState
();
129
void
calculateOverlapLength
(
uint
overlapMs
);
130
131
#ifdef MULTICHANNEL
132
virtual
LONG_SAMPLETYPE
calcCrossCorrMulti
(
const
SAMPLETYPE
*mixingPos,
const
SAMPLETYPE
*compare)
const
;
133
#endif
134
virtual
LONG_SAMPLETYPE
calcCrossCorrStereo
(
const
SAMPLETYPE
*mixingPos,
const
SAMPLETYPE
*compare)
const
;
135
virtual
LONG_SAMPLETYPE
calcCrossCorrMono
(
const
SAMPLETYPE
*mixingPos,
const
SAMPLETYPE
*compare)
const
;
136
137
#ifdef MULTICHANNEL
138
virtual
uint
seekBestOverlapPositionMulti
(
const
SAMPLETYPE
*refPos);
139
virtual
uint
seekBestOverlapPositionMultiQuick
(
const
SAMPLETYPE
*refPos);
140
#endif
141
virtual
uint
seekBestOverlapPositionStereo
(
const
SAMPLETYPE
*refPos);
142
virtual
uint
seekBestOverlapPositionStereoQuick
(
const
SAMPLETYPE
*refPos);
143
virtual
uint
seekBestOverlapPositionMono
(
const
SAMPLETYPE
*refPos);
144
virtual
uint
seekBestOverlapPositionMonoQuick
(
const
SAMPLETYPE
*refPos);
145
uint
seekBestOverlapPosition
(
const
SAMPLETYPE
*refPos);
146
147
#ifdef MULTICHANNEL
148
virtual
void
overlapMulti
(
SAMPLETYPE
*
output
,
const
SAMPLETYPE
*input)
const
;
149
#endif
150
virtual
void
overlapStereo
(
SAMPLETYPE
*
output
,
const
SAMPLETYPE
*input)
const
;
151
virtual
void
overlapMono
(
SAMPLETYPE
*
output
,
const
SAMPLETYPE
*input)
const
;
152
153
void
clearMidBuffer
();
154
void
overlap
(
SAMPLETYPE
*
output
,
const
SAMPLETYPE
*input,
uint
ovlPos)
const
;
155
156
#ifdef MULTICHANNEL
157
void
precalcCorrReference
();
158
#endif
159
void
precalcCorrReferenceMono
();
160
void
precalcCorrReferenceStereo
();
161
162
void
processNominalTempo
();
163
168
void
processSamples
();
169
170
public
:
171
TDStretch
();
172
virtual
~TDStretch
();
173
176
void
*
operator
new
(
size_t
s);
177
181
static
TDStretch
*
newInstance
();
182
184
FIFOSamplePipe
*
getOutput
() {
return
&
outputBuffer
; };
185
187
FIFOSamplePipe
*
getInput
() {
return
&
inputBuffer
; };
188
191
void
setTempo
(
float
newTempo);
192
194
virtual
void
clear
();
195
197
void
clearInput
();
198
200
void
setChannels
(
uint
numChannels);
201
204
void
enableQuickSeek
(
BOOL
enable);
205
207
BOOL
isQuickSeekEnabled
()
const
;
208
211
//
217
void
setParameters
(
uint
sampleRate
,
218
uint
sequenceMS = DEFAULT_SEQUENCE_MS,
219
uint
seekwindowMS = DEFAULT_SEEKWINDOW_MS,
220
uint
overlapMS = DEFAULT_OVERLAP_MS
221
);
222
226
void
getParameters
(
uint
*pSampleRate,
uint
*pSequenceMs,
uint
*pSeekWindowMs,
uint
*pOverlapMs);
227
230
virtual
void
putSamples
(
231
const
SAMPLETYPE
*
samples
,
232
uint
numSamples
233
234
);
235
};
236
237
// Implementation-specific class declarations:
238
239
#ifdef ALLOW_SSE2
240
241
class
TDStretchSSE2
:
public
TDStretch
242
{
243
protected
:
244
#ifdef MULTICHANNEL
245
double
calcCrossCorrMulti
(
const
float
*mixingPos,
const
float
*compare)
const
;
246
virtual
void
overlapMulti
(
float
*
output
,
const
float
*input)
const
;
247
#endif
248
double
calcCrossCorrStereo
(
const
float
*mixingPos,
const
float
*compare)
const
;
249
virtual
void
overlapStereo
(
float
*output,
const
float
*input)
const
;
250
};
251
252
#endif
253
254
#ifdef ALLOW_SSE3
255
256
class
TDStretchSSE3
:
public
TDStretchSSE2
257
{
258
protected
:
259
#ifdef MULTICHANNEL
260
double
calcCrossCorrMulti
(
const
float
*mixingPos,
const
float
*compare)
const
;
261
#endif
262
double
calcCrossCorrStereo
(
const
float
*mixingPos,
const
float
*compare)
const
;
263
};
264
265
#endif
266
267
#ifdef ALLOW_MMX
268
269
class
TDStretchMMX
:
public
TDStretch
270
{
271
protected
:
272
#ifdef USE_MULTI_MMX
273
#ifdef MULTICHANNEL
274
long
calcCrossCorrMulti
(
const
short
*mixingPos,
const
short
*compare)
const
;
275
#endif
276
#endif
277
long
calcCrossCorrStereo
(
const
short
*mixingPos,
const
short
*compare)
const
;
278
virtual
void
overlapStereo
(
short
*
output
,
const
short
*input)
const
;
279
virtual
void
clearCrossCorrState
();
280
};
281
#endif
282
283
}
284
#endif
Generated on Wed May 22 2013 06:59:51 for MythTV by
1.8.1.2