Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
fc1b1f9b
Commit
fc1b1f9b
authored
11 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Makes speech/music detection work with FIXED_POINT (code still float)
parent
3ab03e05
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/analysis.c
+5
-1
5 additions, 1 deletion
src/analysis.c
src/mlp.c
+30
-5
30 additions, 5 deletions
src/mlp.c
src/mlp.h
+2
-2
2 additions, 2 deletions
src/mlp.h
src/tansig_table.h
+1
-1
1 addition, 1 deletion
src/tansig_table.h
with
38 additions
and
9 deletions
src/analysis.c
+
5
−
1
View file @
fc1b1f9b
...
...
@@ -327,6 +327,10 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
{
float
binE
=
out
[
i
].
r
*
(
float
)
out
[
i
].
r
+
out
[
N
-
i
].
r
*
(
float
)
out
[
N
-
i
].
r
+
out
[
i
].
i
*
(
float
)
out
[
i
].
i
+
out
[
N
-
i
].
i
*
(
float
)
out
[
N
-
i
].
i
;
#ifdef FIXED_POINT
/* FIXME: It's probably best to change the BFCC filter initial state instead */
binE
*=
5.55e-17
f
;
#endif
E
+=
binE
;
tE
+=
binE
*
tonality
[
i
];
nE
+=
binE
*
2
.
f
*
(.
5
f
-
noisiness
[
i
]);
...
...
@@ -479,7 +483,7 @@ void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, con
features
[
23
]
=
info
->
tonality_slope
;
features
[
24
]
=
tonal
->
lowECount
;
#ifndef
FIXED_POINT
#ifndef
DISABLE_FLOAT_API
mlp_process
(
&
net
,
features
,
frame_probs
);
frame_probs
[
0
]
=
.
5
f
*
(
frame_probs
[
0
]
+
1
);
/* Curve fitting between the MLP probability and the actual probability */
...
...
This diff is collapsed.
Click to expand it.
src/mlp.c
+
30
−
5
View file @
fc1b1f9b
...
...
@@ -35,7 +35,7 @@
#include
"tansig_table.h"
#define MAX_NEURONS 100
#if
def FIXED_POINT
#if
0
static inline opus_val16 tansig_approx(opus_val32 _x) /* Q19 */
{
int i;
...
...
@@ -62,11 +62,11 @@ static inline opus_val16 tansig_approx(opus_val32 _x) /* Q19 */
}
#else
/*extern const float tansig_table[501];*/
static
inline
opus_val16
tansig_approx
(
opus_val16
x
)
static
inline
float
tansig_approx
(
float
x
)
{
int
i
;
opus_val16
y
,
dy
;
opus_val16
sign
=
1
;
float
y
,
dy
;
float
sign
=
1
;
if
(
x
>=
8
)
return
1
;
if
(
x
<=-
8
)
...
...
@@ -85,6 +85,7 @@ static inline opus_val16 tansig_approx(opus_val16 x)
}
#endif
#if 0
void mlp_process(const MLP *m, const opus_val16 *in, opus_val16 *out)
{
int j;
...
...
@@ -108,4 +109,28 @@ void mlp_process(const MLP *m, const opus_val16 *in, opus_val16 *out)
out[j] = tansig_approx(EXTRACT16(PSHR32(sum,17)));
}
}
#else
void
mlp_process
(
const
MLP
*
m
,
const
float
*
in
,
float
*
out
)
{
int
j
;
float
hidden
[
MAX_NEURONS
];
const
float
*
W
=
m
->
weights
;
/* Copy to tmp_in */
for
(
j
=
0
;
j
<
m
->
topo
[
1
];
j
++
)
{
int
k
;
float
sum
=
*
W
++
;
for
(
k
=
0
;
k
<
m
->
topo
[
0
];
k
++
)
sum
=
sum
+
in
[
k
]
**
W
++
;
hidden
[
j
]
=
tansig_approx
(
sum
);
}
for
(
j
=
0
;
j
<
m
->
topo
[
2
];
j
++
)
{
int
k
;
float
sum
=
*
W
++
;
for
(
k
=
0
;
k
<
m
->
topo
[
1
];
k
++
)
sum
=
sum
+
hidden
[
k
]
**
W
++
;
out
[
j
]
=
tansig_approx
(
sum
);
}
}
#endif
This diff is collapsed.
Click to expand it.
src/mlp.h
+
2
−
2
View file @
fc1b1f9b
...
...
@@ -33,9 +33,9 @@
typedef
struct
{
int
layers
;
const
int
*
topo
;
const
opus_val16
*
weights
;
const
float
*
weights
;
}
MLP
;
void
mlp_process
(
const
MLP
*
m
,
const
opus_val16
*
in
,
opus_val16
*
out
);
void
mlp_process
(
const
MLP
*
m
,
const
float
*
in
,
float
*
out
);
#endif
/* _MLP_H_ */
This diff is collapsed.
Click to expand it.
src/tansig_table.h
+
1
−
1
View file @
fc1b1f9b
/* This file is auto-generated by gen_tables */
static
const
opus_val16
tansig_table
[
201
]
=
{
static
const
float
tansig_table
[
201
]
=
{
0
.
000000
f
,
0
.
03
9979
f
,
0
.
07
9830
f
,
0
.
119427
f
,
0
.
158649
f
,
0
.
197375
f
,
0
.
235496
f
,
0
.
272905
f
,
0
.
309507
f
,
0
.
345214
f
,
0
.
379949
f
,
0
.
413644
f
,
0
.
446244
f
,
0
.
477700
f
,
0
.
507977
f
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment