Tactility modules refactored (#13)
* refactor modules * moved esp_lvgl_port to libs/ * added missing file * fix for sim build * various sim/pc fixes * lvgl improvements * added missing cmake files
This commit is contained in:
committed by
GitHub
parent
a94baf0d00
commit
6bd65abbb4
Executable
+33
@@ -0,0 +1,33 @@
|
||||
import numpy as np
|
||||
import librosa
|
||||
import math
|
||||
import sys
|
||||
|
||||
print("Loading file")
|
||||
audio, sample_rate = librosa.load(sys.argv[1], duration=60, offset=0, sr=15360)
|
||||
|
||||
print("Getting spectrum")
|
||||
spectrum = librosa.stft(audio)
|
||||
S = np.abs(spectrum)
|
||||
|
||||
fout = open("spectrum.h", "w")
|
||||
|
||||
print("Writing file")
|
||||
fn = 36
|
||||
fs = int(len(S) / fn)
|
||||
fout.write("const uint16_t spectrum[][4] = {\n")
|
||||
for t in range(0,len(S[0]-1)):
|
||||
fout.write("{ ")
|
||||
f_prev = 0
|
||||
for f in [8, 45, 300, 600]:
|
||||
v = 0
|
||||
for i in range(f_prev, f): v += S[i][t]
|
||||
if v != 0: v = int(v/30)
|
||||
if v < 0: v = 0
|
||||
f_prev = f
|
||||
fout.write(str(int(v)) + ", ")
|
||||
fout.write("},\n")
|
||||
fout.write("};\n")
|
||||
fout.close()
|
||||
|
||||
print("Finished")
|
||||
Reference in New Issue
Block a user