Automatic stereo/mono detection
This commit is contained in:
parent
cd68bb0058
commit
e53df74d68
|
@ -283,8 +283,20 @@ def get_freq(song_name, offset, step, songlen, data, display=False):
|
|||
|
||||
return frequencies
|
||||
|
||||
def is_data_stereo(raw_global_data:list) -> bool:
|
||||
"""
|
||||
raw_global_data : list
|
||||
"""
|
||||
try:
|
||||
assert(raw_global_data[0][0])
|
||||
except IndexError:
|
||||
return False
|
||||
except AssertionError:
|
||||
return True
|
||||
return True
|
||||
|
||||
def void_freq(song_name, offset, songlen, increment, minfreq, maxfreq, upperthr, ampthr, ampfreq, ampval, leniency, write, linear, is_stereo, output_file="trimmed.wav"):
|
||||
|
||||
def void_freq(song_name, offset, songlen, increment, minfreq, maxfreq, upperthr, ampthr, ampfreq, ampval, leniency, write, linear, output_file="trimmed.wav"):
|
||||
"""
|
||||
song_name : string
|
||||
offset : int
|
||||
|
@ -315,7 +327,7 @@ def void_freq(song_name, offset, songlen, increment, minfreq, maxfreq, upperthr,
|
|||
subprocess.run(["clear"])
|
||||
subprocess.run(["rm", "crop.wav"])
|
||||
|
||||
if(is_stereo):
|
||||
if(is_data_stereo(raw_global_data)):
|
||||
print("Converting to mono...")
|
||||
for x in range(len(raw_global_data)):
|
||||
global_data[x] = raw_global_data[x][0]/2 + raw_global_data[x][1]/2
|
||||
|
@ -448,7 +460,7 @@ def process_song(filename, bpm, offset0=0, div_len_factor=1, n_iter_2=-1, thresh
|
|||
|
||||
filtered_name = f"{filename}_trimmed.wav"
|
||||
|
||||
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, is_stereo=True, output_file=filtered_name)
|
||||
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)
|
||||
|
@ -458,7 +470,7 @@ def process_song(filename, bpm, offset0=0, div_len_factor=1, n_iter_2=-1, thresh
|
|||
|
||||
|
||||
def main():
|
||||
data = process_song("tetris_4.wav", 160, n_iter_2 = 64)
|
||||
data = process_song("audio.wav", 160, n_iter_2 = 64)
|
||||
#print(data)
|
||||
print("Program finished with return 0")
|
||||
|
||||
|
|
Loading…
Reference in New Issue