Add frequence_process plotting to compare original with detected
This commit is contained in:
parent
d2af367f2d
commit
3d727f3fec
|
@ -0,0 +1,29 @@
|
|||
import slider as sl
|
||||
import sound_process
|
||||
from tkinter import filedialog as fd
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
def process_with_map():
|
||||
filename = fd.askopenfilename()
|
||||
beatmap = sl.Beatmap.from_path(filename)
|
||||
timing = beatmap.timing_points[0]
|
||||
bpm = timing.bpm
|
||||
offset = timing.offset.total_seconds() * 1000
|
||||
data = sound_process.process_song(beatmap.audio_filename, bpm, offset0=offset)
|
||||
|
||||
timings, amplitudes, freqs = [x[0].total_seconds() for x in data], [x[1] for x in data], [x[2] for x in data]
|
||||
|
||||
original_times = [x.time.total_seconds() for x in beatmap.hit_objects(spinners=False) if x.time.total_seconds() <= timings[len(timings) - 1]]
|
||||
|
||||
#bx.scatter(original_times, ys=10, zs=0)
|
||||
plt.scatter(timings, amplitudes, marker="x", c="red")
|
||||
for x in original_times:
|
||||
plt.axvline(x=x)
|
||||
|
||||
plt.show()
|
||||
|
||||
def main():
|
||||
process_with_map()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -480,13 +480,13 @@ def process_song(filename, bpm, offset0=0, div_len_factor=1, n_iter_2=-1, thresh
|
|||
void_freq(filename, offset, min(song_len, offset+div_len*(n_iter+1)+0.01), 4*60/bpm, minfreq=0, maxfreq=220, upperthr=5000, ampthr=60, ampfreq = 1200, ampval = 5.0, leniency = 0.005, write=True, linear=False, output_file=filtered_name)
|
||||
#void_freq(filename, offset, offset+div_len*(n_iter+1)+0.01, 4*60/bpm, minfreq=0, maxfreq=330, upperthr=2500, ampthr=60, ampfreq = 1200, ampval = 1/2000, leniency = 0.0, write=True, linear=True, output_file=filtered_name)
|
||||
datares = filter_n_percent_serial(filtered_name, offset, n_iter, div_len, threshold)
|
||||
datares = snap(datares, 44100, bpm, 4, True)
|
||||
frequencies = get_freq(filtered_name, offset, div_len, div_len*n_iter, datares, True)
|
||||
datares = snap(datares, 44100, bpm, 4, False)
|
||||
frequencies = get_freq(filtered_name, offset, div_len, div_len*n_iter, datares, False)
|
||||
Path(f"{filename}_trimmed.wav").unlink()
|
||||
return convert_tuple(datares, frequencies)
|
||||
|
||||
def main():
|
||||
data = process_song("tetris_4.wav", 160, n_iter_2 = 64)
|
||||
data = process_song("audio.mp3", 160, n_iter_2 = 64)
|
||||
#print(data)
|
||||
print("Program finished with return 0")
|
||||
|
||||
|
|
Loading…
Reference in New Issue