Skip to content

Commit 1953733

Browse files
committed
Add fft used info
1 parent f0e1fff commit 1953733

File tree

7 files changed

+13
-3
lines changed

7 files changed

+13
-3
lines changed

flatten/dsp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
5151
'features': features,
5252
'graphs': [],
5353
'labels': labels,
54+
'fft_used': [],
5455
'output_config': { 'type': 'flat', 'shape': { 'width': len(features) } }
5556
}
5657

image/dsp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
7676
image_config = { 'width': int(width), 'height': int(height), 'channels': num_channels, 'frames': frame_count }
7777
output_config = { 'type': 'image', 'shape': image_config }
7878

79-
return { 'features': all_features, 'graphs': graphs, 'output_config': output_config }
79+
return { 'features': all_features, 'graphs': graphs, 'output_config': output_config, 'fft_used': [] }
8080

8181
if __name__ == "__main__":
8282
parser = argparse.ArgumentParser(description='Returns raw data')

mfcc/dsp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
8888
return {
8989
'features': features.tolist(),
9090
'graphs': graphs,
91+
'fft_used': [ num_filters, fft_length ],
9192
'output_config': {
9293
'type': 'spectrogram',
9394
'shape': {

mfe/dsp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
122122
return {
123123
'features': features.tolist(),
124124
'graphs': graphs,
125+
'fft_used': [ fft_length ],
125126
'output_config': {
126127
'type': 'spectrogram',
127128
'shape': {

raw/dsp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
1313
return {
1414
'features': raw_data * scale_axes,
1515
'graphs': [],
16+
'fft_used': [],
1617
'output_config': { 'type': 'flat', 'shape': { 'width': len(raw_data) } }
1718
}
1819

spectral-analysis/dsp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
def filter(type, freq_hz, cut_off_freq, filt_order, data):
1010
Wn = cut_off_freq / freq_hz # Normalized frequency (6 / 62.5) = 0.096
1111

12+
# Catch when frequency too low
13+
if (Wn >= 1.0):
14+
raise Exception('Sample frequency must be greater than ' + str(cut_off_freq) + 'Hz. Try increasing the frequency in the "Impulse design" page.')
15+
1216
[b, a] = signal.butter(filt_order, Wn=Wn, btype=type)
1317

1418
filtered_data = lfilter(b,a,data)
@@ -221,6 +225,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
221225
'features': np.array(features).tolist(),
222226
'graphs': graphs,
223227
'labels': labels,
228+
'fft_used': [ fft_length ],
224229
'output_config': { 'type': 'flat', 'shape': { 'width': len(features) } }
225230
}
226231

spectrogram/dsp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
120120
return {
121121
'features': features.tolist(),
122122
'graphs': graphs,
123+
'fft_used': [ fft_length ],
123124
'output_config': {
124125
'type': 'spectrogram',
125126
'shape': {
@@ -156,8 +157,8 @@ def generate_features(implementation_version, draw_graphs, raw_data, axes, sampl
156157
raw_axes = args.axes.split(',')
157158

158159
try:
159-
processed = generate_features(2, args.draw_graphs, raw_features, raw_axes, args.frequency,
160-
args.frame_length, args.frame_stride, args.num_filters, args.fft_length, args.noise_floor_db)
160+
processed = generate_features(3, args.draw_graphs, raw_features, raw_axes, args.frequency,
161+
args.frame_length, args.frame_stride, args.fft_length, args.show_axes, args.noise_floor_db)
161162

162163
print('Begin output')
163164
print(json.dumps(processed))

0 commit comments

Comments
 (0)