-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgstclassify.h
155 lines (133 loc) · 3.5 KB
/
gstclassify.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* Copyright 2013 Douglas Bagnall <[email protected]> LGPL */
#ifndef __GST_AUDIO_CLASSIFY_H__
#define __GST_AUDIO_CLASSIFY_H__
#include <gst/audio/gstaudiofilter.h>
#include <gst/audio/audio.h>
#include "recur-common.h"
#include "recur-nn.h"
#include "mfcc.h"
#include "badmaths.h"
#include "pgm_dump.h"
G_BEGIN_DECLS
#define CLASSIFY_MAX_CHANNELS 1000
#define CLASSIFY_MIN_CHANNELS 1
#define CLASSIFY_RATE 8000
#define CLASSIFY_VALUE_SIZE 2
#define CLASSIFY_N_FFT_BINS 32
#define CLASSIFY_RNN_FLAGS (RNN_NET_FLAG_STANDARD | \
RNN_NET_FLAG_BPTT_ADAPTIVE_MIN_ERROR)
#define CLASSIFY_FORMAT "S16LE"
/*sizeof(S16LE)*/
typedef s16 audio_sample;
#define RECUR_AUDIO_BITS (8 * sizeof(audio_sample))
#define PERIODIC_SAVE_NET 0
#define TRY_RELOAD 1
#define PERIODIC_PGM_DUMP 2047
#define PERIODIC_PGM_DUMPEES "how ihw biw"
#define PGM_DUMP_FEATURES 0
#define CLASSIFY_QUEUE_FACTOR 30
#define GST_TYPE_CLASSIFY (gst_classify_get_type())
#define GST_CLASSIFY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLASSIFY,GstClassify))
#define GST_CLASSIFY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLASSIFY,GstClassifyClass))
#define GST_IS_CLASSIFY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLASSIFY))
#define GST_IS_CLASSIFY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLASSIFY))
typedef struct _GstClassify GstClassify;
typedef struct _GstClassifyClass GstClassifyClass;
/*Do not reorder metadata, or insert things in the middle, even though the
packing is loose and the order haphazard. Only add things at the end, and
keep the same order in the metadata strings.
*/
struct ClassifyMetadata {
const char *classes;
float min_freq;
float max_freq;
float knee_freq;
int mfccs;
int window_size;
const char *basename;
int delta_features;
float focus_freq;
float lag;
int intensity_feature;
float confirmation_lag;
const char *features_offset;
const char *features_scale;
};
typedef struct _ClassifyClassEvent {
int channel;
int class_group;
int window_no;
int target;
} ClassifyClassEvent;
typedef struct _ClassifyClassGroup {
int offset;
int n_classes;
char *classes;
} ClassifyClassGroup;
typedef struct _ClassifyChannel
{
RecurNN *net;
float *features;
float *prev_features;
float *pcm_now;
float *pcm_next;
int *group_target;
int *group_winner;
TemporalPPM *mfcc_image;
} ClassifyChannel;
struct _GstClassify
{
GstAudioFilter audiofilter;
GstAudioInfo *info;
RecurNN *net;
RecurNN **subnets;
ClassifyChannel *channels;
int n_channels;
int n_groups;
ClassifyClassGroup *class_groups;
s16 *audio_queue;
int read_offset;
int write_offset;
RecurAudioBinner *mfcc_factory;
const char *net_filename;
const char *basename;
int queue_size;
int mfccs;
ClassifyClassEvent *class_events;
int n_class_events;
int class_events_index;
float momentum_soft_start;
int window_size;
int window_no;
int ignored_windows;
int training;
int random_alignment;
int learning_style;
float *error_weight;
GValue *pending_properties;
TemporalPPM *error_image;
int delta_features;
int intensity_feature;
float lag;
float confirmation_lag;
float weight_noise;
float *feature_offsets;
int n_feature_offsets;
float *feature_scales;
int n_feature_scales;
FILE *features_file;
u32 *seen_training_counts;
u32 *used_training_counts;
float balanced_training_bias;
};
struct _GstClassifyClass
{
GstAudioFilterClass parent_class;
};
GType gst_classify_get_type(void);
G_END_DECLS
#endif /* __GST_AUDIO_CLASSIFY_H__ */