-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bindings.py
More file actions
58 lines (46 loc) · 1.88 KB
/
test_bindings.py
File metadata and controls
58 lines (46 loc) · 1.88 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
import sys
import os
# Add build directory to path so we can import the module
sys.path.append(os.path.join(os.getcwd(), 'cmake-build-release'))
import pytotune
def test_scale():
print("Testing scale tuning (default pitch_range omitted)...")
wav_path = "tests/data/voice_f440_sr44100.wav"
out_path = "tests/testoutput/out_scale.wav"
try:
scale = pytotune.Scale.fromName("C major")
# call without pitch_range (should use default HUMAN)
pytotune.roundToScale(wav_path, scale, out_path)
print(f"Success! Output saved to {out_path}")
except Exception as e:
print(f"Error: {e}")
# Example: use singerToPitchRange helper
try:
pr = pytotune.singerToPitchRange("man")
out_path2 = "tests/testoutput/out_scale_man.wav"
pytotune.roundToScale(wav_path, scale, out_path2, pr)
print(f"Success with singer range! Output saved to {out_path2}")
except Exception as e:
print(f"Error using singer range: {e}")
def test_midi():
print("\nTesting midi tuning (default pitch_range omitted)...")
wav_path = "tests/data/voice_f440_sr44100.wav"
midi_path = "tests/data/test.mid"
out_path = "tests/testoutput/out_midi.wav"
try:
# call without pitch_range (should use default HUMAN)
pytotune.matchMidi(wav_path, midi_path, out_path)
print(f"Success! Output saved to {out_path}")
except Exception as e:
print(f"Error: {e}")
# Example: pass an explicit numeric PitchRange
try:
pr = pytotune.PitchRange(200.0, 800.0)
out_path2 = "tests/testoutput/out_midi_customrange.wav"
pytotune.matchMidi(wav_path, midi_path, out_path2, pr)
print(f"Success with explicit PitchRange! Output saved to {out_path2}")
except Exception as e:
print(f"Error with explicit PitchRange: {e}")
if __name__ == "__main__":
test_midi()
test_scale()