Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
ITABase
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Security & Compliance
Security & Compliance
Dependency List
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
ed7c0bf9
Commit
ed7c0bf9
authored
Jul 16, 2019
by
henryjandrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a new enumerated type for the kind of interpolation
parent
178b2a13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
src/ITAInterpolation.cpp
src/ITAInterpolation.cpp
+9
-10
No files found.
src/ITAInterpolation.cpp
View file @
ed7c0bf9
...
...
@@ -16,17 +16,16 @@ float spline_cubic_val_equidistant( const float fX, const float* y, const std::v
bool
CITASampleLinearInterpolation
::
Interpolate
(
const
ITASampleBuffer
*
pInput
,
const
int
iInputLength
,
const
int
iInputStartOffset
,
ITASampleBuffer
*
pOutput
,
const
int
iOutputLength
,
const
int
iOutputOffset
/*=0*/
)
const
{
assert
(
pOutput
->
length
()
>=
iOutputLength
+
iOutputOffset
);
assert
(
pOutput
->
GetLength
()
>=
iOutputLength
+
iOutputOffset
);
assert
(
pInput
->
GetLength
()
>=
iInputLength
+
iInputStartOffset
);
// Interpolation ist nur mglich, wenn der Eingabe-Offset auf dem Eingabepuffer
// grer oder gleich 1 ist, da sonst keine Sttzwerte vorhanden sind.
assert
(
iInputStartOffset
>
0
);
if
(
iInputStartOffset
<
1
)
return
false
;
// Resamplingfaktor
float
r
=
(
iInputLength
-
iInputStartOffset
+
1
)
/
(
float
)
iOutputLength
;
float
r
=
iInputLength
/
(
float
)
iOutputLength
;
// TODO klren ob diese resampling grenzen berhaupt gelten, theor. gibt es keine einschrnkung hier!
...
...
@@ -41,8 +40,8 @@ bool CITASampleLinearInterpolation::Interpolate( const ITASampleBuffer* pInput,
// Samples des berlappungspuffers am Anfang einbeziehen
for
(
int
i
=
0
;
i
<
iOutputLength
;
i
++
)
{
//
Position in der Eingabe berechnen
float
x_input
=
(
i
+
1
)
*
r
;
//
Calculate the position in the input buffer
float
x_input
=
(
i
+
1
)
*
r
+
iInputStartOffset
-
1
;
// Die Position des letzten Samples muss bereinstimmen mit dem letzten
// Eingabesample, dann wurde die Zeit erfolgreich eingeholt bzw.
...
...
@@ -56,7 +55,7 @@ bool CITASampleLinearInterpolation::Interpolate( const ITASampleBuffer* pInput,
float
frac
=
x_input
-
(
float
)
a
;
// Die Linke Seite liegt immer innerhalb des Ausgangs
assert
(
(
a
>=
0
)
&&
(
a
<
iInputLength
)
);
assert
(
(
a
>=
0
)
&&
(
b
<
(
iInputLength
+
iInputStartOffset
)
)
);
// Sample genau getroffen (z.B. a=b=0)
if
(
a
==
b
)
...
...
@@ -66,7 +65,7 @@ bool CITASampleLinearInterpolation::Interpolate( const ITASampleBuffer* pInput,
else
{
// Zwischenwert anhand linkem und rechtem Sttzwert ermitteln
assert
(
(
b
>=
1
)
&&
(
b
<
iInputLength
)
);
assert
(
(
b
>=
1
)
&&
(
b
<
iInputLength
+
iInputStartOffset
)
);
// Steigung (leicht lesbare Implementierung, wird vom Compiler wegoptimiert)
float
left_val
=
(
*
pInput
)[
a
];
...
...
@@ -86,7 +85,7 @@ bool CITASampleLinearInterpolation::Interpolate( const ITASampleBuffer* pInput,
for
(
int
i
=
0
;
i
<
iOutputLength
;
i
++
)
{
// Position in der Eingabe berechnen
float
x_input
=
(
i
+
1
)
*
r
;
float
x_input
=
(
i
+
1
)
*
r
+
iInputStartOffset
-
1
;
// Linkes/rechtes Nachbarsample in der Eingabe
int
a
=
(
int
)
floor
(
x_input
);
...
...
@@ -96,7 +95,7 @@ bool CITASampleLinearInterpolation::Interpolate( const ITASampleBuffer* pInput,
float
frac
=
x_input
-
(
float
)
a
;
// Die Linke Seite liegt immer innerhalb des Ausgangs
assert
(
(
a
>=
0
)
&&
(
a
<
(
iInputLength
)
)
);
assert
(
(
a
>=
iInputStartOffset
-
1
)
&&
(
b
<
(
iInputLength
+
iInputStartOffset
)
)
);
// Sample genau getroffen (z.B. a=b=0)
if
(
a
==
b
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment