-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_ELKTRN - WF Check Region.pyscript
107 lines (79 loc) · 3.01 KB
/
_ELKTRN - WF Check Region.pyscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""Check if the sample is the correct length and has regions."""
import os
# from enveditor import Editor, EditorSample, Utils, MEEditor, ScriptDialog, Sample
from enveditor import EditorSample, Utils
from akscripts.edison.remove_all_regions import remove_all_regions
from akscripts.edison.set_sample_to_mono_sum_stereo import set_sample_to_mono_sum_stereo
from akscripts.get_files_to_process import get_files_to_process
from datetime import datetime
from akscripts.persistent_variables import (
read_index,
write_index,
read_run_start_date,
write_run_start_date,
read_last_completed_date,
write_last_completed_date,
)
WF_LENGTH = 367
WORK_DIR = "C:\\github\\elektron\\src\\akwt_projects\\"
VAR_PREFIX = "elektron-set-loop-points"
def not_correct_length():
"""Check if the sample length is correct."""
return EditorSample.Length != WF_LENGTH
def has_regions():
"""Check if the sample has regions."""
return EditorSample.RegionCount > 0
def do_the_things():
"""Do the things."""
set_sample_to_mono_sum_stereo()
remove_all_regions()
Utils.ProgressMsg("This needs to be fixed and saved.", 100, 100)
def main():
"""Main function."""
## Get initial variables from textfiles
start_index = read_index(VAR_PREFIX)
if start_index == 0:
write_run_start_date(VAR_PREFIX)
start_date = read_run_start_date(VAR_PREFIX)
last_completed_date = read_last_completed_date(VAR_PREFIX)
stop_processing = False
done_message = "All done!"
waveforms_to_process = get_files_to_process(WORK_DIR, r" - \d{2}.wav")
waveforms_to_process_length = len(waveforms_to_process)
for i, file in enumerate(waveforms_to_process):
if stop_processing:
break
done_message += f"\n{file}:"
Utils.ProgressMsg(
f"{file}",
i,
waveforms_to_process_length,
)
file_modifies_date = os.path.getmtime(file)
# 2025-03-12 13:42:51
# threshold_date = datetime(2025, 3, 12, 13, 42, 51).timestamp()
threshold_date = datetime(2025, 3, 12, 12, 0, 0).timestamp()
if file_modifies_date > threshold_date and file_modifies_date < start_date:
EditorSample.LoadFromFile(file)
do_the_things()
write_index(i + i, VAR_PREFIX)
stop_processing = True
break
if file_modifies_date < start_date and file_modifies_date > last_completed_date:
EditorSample.LoadFromFile(file)
do_the_things()
write_index(i + i, VAR_PREFIX)
stop_processing = True
break
if start_index == i and file_modifies_date > last_completed_date:
EditorSample.LoadFromFile(file)
do_the_things()
write_index(i + i, VAR_PREFIX)
stop_processing = True
break
if not stop_processing:
write_last_completed_date(VAR_PREFIX)
write_index(0, VAR_PREFIX)
Utils.ShowMessage(done_message)
if __name__ == "__main__":
main()