diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4ac73b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*/target/ +*/__pycache__/ diff --git a/timing-diagram/diagram.py b/timing-diagram/diagram.py new file mode 100644 index 0000000..02ed24f --- /dev/null +++ b/timing-diagram/diagram.py @@ -0,0 +1,67 @@ +import os +import subprocess + +SPEED_FACTOR=1 +LOW_BASE_FREQ=1000 +HIGH_BASE_FREQ=1050 +SECTION_DIFF=-200 + +## ADVANCED CONFIG +SAMPLE_RATE=10000 +## END OF CONFIG + +example_new="1 0@1.33 1@3.3 0@3.5 1@3.6 0@3.8" + +def get_args(args): + a = args.split("@") + return (a[0], float(a[1])) + +def convert(syn): + first_state = syn[0] + slist = syn.split(" ")[1:] + tarr = list() + tarr.append((first_state,)) + time_offset = 0 + for ti in range(len(slist)): + state, time = get_args(slist[ti]) + tarr[ti] = (tarr[ti][0], time-time_offset) + time_offset = time + tarr.append((state,)) + tarr[len(tarr)-1] = (tarr[len(tarr)-1][0], 100) + return tarr + +def create_commands(example): + return [f"sox -r 10000 -n _tmp_exmp.wav synth {example[i][1]} sine {1000 + (i*50)}" for i in range(len(example))] + +print(create_commands(convert(example_new))) +exit(1) + +LBF=str(LOW_BASE_FREQ) +HBF=str(HIGH_BASE_FREQ) + +METRONOME_CLOCK=MC=f"sox -r {str(SAMPLE_RATE)} -n metronome.wav synth .005 sine 4000".split(" ") + +SPEED_FACTOR=SF=SPEED_FACTOR**-1 + +SINE_LINE = ((f"{LBF} {SF} {HBF} {SF} ") * 10).strip(" ") + +def add_metronome(file_name): + if not os.path.exists("metronome.wav"): + subprocess.call(MC) + subprocess.run(["sox", "--combine", "merge", f"{file_name}", "metronome.wav", f"{file_name}_met.wav"]) + subprocess.run(["mv", f"{file_name}_met.wav", f"{file_name}"]) + +def create_tones(tone_list, final_name): + split_line = SINE_LINE.split(" ") + idex = range(0, len(split_line), 2) + + for i in idex: + print(f"sox -r 10000 -n _tmp_output_{str(i)}.wav synth {split_line[i+1]} sine {split_line[i]}") + subprocess.run(["sox", "-r", "10000", "-n", f"_tmp_output_{str(i)}.wav", "synth", split_line[i+1], "sine", split_line[i]]) + add_metronome(f"_tmp_output_{str(i)}.wav") + + files = [f"_tmp_output_{str(i)}_met.wav" for i in idex] + subprocess.call(["sox", *files, f"{final_name}.wav"]) + #subprocess.call(["rm", "_tmp_output_*"]) + +create_tones(SINE_LINE, "final") diff --git a/timing-diagram/final.wav b/timing-diagram/final.wav new file mode 100644 index 0000000..2b14f97 Binary files /dev/null and b/timing-diagram/final.wav differ diff --git a/timing-diagram/metronome.wav b/timing-diagram/metronome.wav new file mode 100644 index 0000000..93d7c87 Binary files /dev/null and b/timing-diagram/metronome.wav differ diff --git a/timing-diagram/test.au b/timing-diagram/test.au new file mode 100644 index 0000000..a3e97b8 Binary files /dev/null and b/timing-diagram/test.au differ diff --git a/timing-diagram/test.txt b/timing-diagram/test.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/timing-diagram/test.txt @@ -0,0 +1 @@ + diff --git a/timing-diagram/test.wav b/timing-diagram/test.wav new file mode 100644 index 0000000..2927ed0 Binary files /dev/null and b/timing-diagram/test.wav differ diff --git a/tree/__pycache__/data.cpython-39.pyc b/tree/__pycache__/data.cpython-39.pyc new file mode 100644 index 0000000..4faf793 Binary files /dev/null and b/tree/__pycache__/data.cpython-39.pyc differ