forked from jkmaxwell/medusa_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmedusa_mac.py
More file actions
executable file
·107 lines (88 loc) · 4.1 KB
/
Copy pathmedusa_mac.py
File metadata and controls
executable file
·107 lines (88 loc) · 4.1 KB
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
#!/usr/bin/env python3
import sys
import medusa_core
DEFAULT_INPUT = "medusa64Wavetables.polyend"
DEFAULT_WAVES_DIR = "waves"
DEFAULT_OUTPUT = "recompiled.polyend"
def show_help():
print("""
Medusa Wavetable Tool
Usage:
medusa_mac.py decompile [input.polyend]
medusa_mac.py recompile [input_dir] [output.polyend]
medusa_mac.py process <input_dir> <output_dir>
medusa_mac.py create <input_dir> <output.polyend> [--random]
Commands:
decompile Extract wavetables from .polyend file to WAV files
(defaults to medusa64Wavetables.polyend if not specified)
recompile Create .polyend file from WAV files
(defaults to ./waves/ input and recompiled.polyend output if not specified)
process Convert WAV files to Medusa-compatible format
create Create wavetable bank from a directory of audio files
Use --random to select files randomly instead of alphabetically
""")
def main():
if len(sys.argv) < 2 or sys.argv[1] in ['-h', '--help']:
show_help()
return
command = sys.argv[1]
if command == 'decompile':
# Use default input file if none specified
input_file = sys.argv[2] if len(sys.argv) > 2 else DEFAULT_INPUT
result = medusa_core.decompile_wavetable(input_file)
if result['success']:
print(f"\nDecompiling {result['num_wavetables']} wavetables to {result['output_dir']}...")
for file in result['files']:
print(f"Extracted wavetable to {file}")
print(f"\nDecompiled {result['num_wavetables']} wavetables successfully")
else:
print(f"Error decompiling wavetable: {result['error']}")
elif command == 'recompile':
# Use default input/output if not specified
input_dir = sys.argv[2] if len(sys.argv) > 2 else DEFAULT_WAVES_DIR
output_file = sys.argv[3] if len(sys.argv) > 3 else DEFAULT_OUTPUT
result = medusa_core.recompile_wavetable(input_dir, output_file)
if result['success']:
print(f"\nRecompiling wavetables from {input_dir} to {result['output_file']}...")
for file in result['files']:
print(f"Recompiled wavetable from {file}")
print(f"\nSuccessfully recompiled {result['num_wavetables']} wavetables to {result['output_file']}")
else:
print(f"Error recompiling wavetables: {result['error']}")
elif command == 'process':
if len(sys.argv) != 4:
print("Error: process requires input and output directories")
show_help()
return
result = medusa_core.process_wavs(sys.argv[2], sys.argv[3])
if result['success']:
print(f"\nProcessing WAV files to {result['output_dir']}...")
for file in result['files']:
print(f"Processed {file}")
print(f"\nSuccessfully processed {result['num_files']} WAV files")
print("You can now use 'recompile' to create a .polyend file")
else:
print(f"Error processing WAVs: {result['error']}")
elif command == 'create':
if len(sys.argv) < 4:
print("Error: create requires input directory and output file")
show_help()
return
input_dir = sys.argv[2]
output_file = sys.argv[3]
random_order = '--random' in sys.argv
print(f"\nCreating wavetable bank from {input_dir}")
print(f"Selection mode: {'random' if random_order else 'alphabetical'}")
result = medusa_core.create_wavetable_bank(input_dir, output_file, random_order)
if result['success']:
print(f"\nSuccessfully created wavetable bank:")
print(f"- Output file: {result['output_file']}")
print(f"- Number of wavetables: {result['num_wavetables']}")
print(f"- Source files: {len(result['source_files'])}")
else:
print(f"Error creating wavetable bank: {result['error']}")
else:
print(f"Unknown command: {command}")
show_help()
if __name__ == "__main__":
main()