-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_n_tag.py
executable file
·177 lines (155 loc) · 4.65 KB
/
gen_n_tag.py
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import shutil
import wtcurve
import wttag
# destination paths for tagged files
wav_path = '/home/ftp/audio/Wavetables/WT1/My'
wt_path = os.path.expanduser('~/Music/Bitwig/Library/Wavetables/WT1/My')
h2p_paths = [os.path.expanduser(i) for i in [
'~/.u-he/Zebra2/Modules/Oscillator/My',
'~/.u-he/ZebraHZ/Modules/Oscillator/My'
]]
# samples
sa = 2048
# samples in simple wt waveforms
sa_wt = 1024
# waveforms
wa = 256
# waveforms in simple waveforms
wl = 64
types = ['bezier', 'tanh', 'dline', 'exp']
for t in types:
os.makedirs(os.path.join(wav_path, t), exist_ok=True)
os.makedirs(os.path.join(wt_path, t), exist_ok=True)
for path in h2p_paths:
os.makedirs(os.path.join(path, t), exist_ok=True)
def tpath(d):
for ty in types:
if ty in d:
return ty
return types[-1]
def mk_wav(d):
wtc = wtcurve.WtCurve(d|{'wav': True})
wtc.generate()
fn = wtc.fmt_fname('wav')
dn = os.path.join(wav_path, tpath(d), fn)
tagger = wttag.Tagger({
'num_waveforms': d['num_waveforms'],
'num_samples': d['num_samples'],
'src_file': fn,
'dst_file': dn,
'ov_file': True,
'mkdir': True, 'tag_clm': True})
tagger.tag()
def mk_wt(d):
wtc = wtcurve.WtCurve(d|{'wt': True, 'bitwidth': 16})
wtc.generate()
fn = wtc.fmt_fname('wt')
dn = os.path.join(wt_path, tpath(d), fn)
shutil.move(fn, dn)
def mk_h2p(d):
wtc = wtcurve.WtCurve(d|{'h2p': True})
wtc.generate()
fn = wtc.fmt_fname('h2p')
dn = os.path.join(h2p_paths[0], tpath(d), fn)
shutil.copy(fn, dn)
dn = os.path.join(h2p_paths[1], tpath(d), fn)
shutil.move(fn, dn)
def mk_gif(d):
wtc = wtcurve.WtCurve(d|{'gif': True})
wtc.generate()
def mk_png(d):
wtc = wtcurve.WtCurve(d|{'png': True, 'graph': True})
wtc.generate()
def gen_direct():
print('variable direct')
ga=35
for o in range(-25,26,5):
bdict = {'num_waveforms': wl, 'num_samples': sa, 'dline': True,
'mid_yoffset': o}
mk_wav(bdict)
mk_wav(bdict|{'gauss': ga})
mk_wt(bdict|{'num_samples': sa_wt})
mk_wt(bdict|{'num_samples': sa_wt, 'gauss': ga})
mk_h2p(bdict)
mk_h2p(bdict|{'gauss': ga})
def gen_savgol():
print('savgol')
bdict = {'num_waveforms': wa, 'num_samples': sa, 'savgol': (10, 3)}
mk_wav(bdict)
mk_wt(bdict)
mk_h2p(bdict)
def gen_gauss():
print('gauss')
bdict = {'num_waveforms': wa, 'num_samples': sa, 'gauss': 40}
mk_wav(bdict)
mk_wt(bdict)
mk_h2p(bdict)
def gen_bitcrush():
print('bitcrush')
for bc in [4, 5, 6]:
bdict = {'num_waveforms': wa, 'num_samples': sa, 'bitcrush': bc}
mk_wav(bdict)
mk_wav(bdict|{'dline': True})
mk_wt(bdict)
mk_wt(bdict|{'dline': True})
mk_h2p(bdict)
mk_h2p(bdict|{'dline': True})
def gen_bezier():
print('variable bezier')
for o in range(-25,26,25):
for bz in range(1, -6, -1):
bdict = {'num_waveforms': wa, 'num_samples': sa,
'bezier': bz,'mid_yoffset': o}
mk_wav(bdict)
mk_wt(bdict)
mk_h2p(bdict)
if o == 0:
# all bezier with offset 0 are the same
break
def gen_tanh():
print('variable tanh')
for o in [-25, -15, 0, 15, 25]:
for tanh in range(2, 5, 1):
bdict = {'num_waveforms': wa, 'num_samples': sa, 'tanh': tanh,
'mid_yoffset': o}
mk_wav(bdict)
mk_wt(bdict)
mk_h2p(bdict)
def gen_exp():
print('variable offset/exp')
for e in range(3, 8, 2):
for o in range(-20, 26, 5):
bdict = {'num_waveforms': wa, 'num_samples': sa, 'exp': e,
'mid_yoffset': o}
mk_wav(bdict)
mk_wt(bdict)
mk_h2p(bdict)
def gen_shift():
print('shift')
bdict = {'num_waveforms': wa, 'num_samples': sa, 'mid_yoffset': 0,
'shift': sa // 2, 'mid_width_pct': 100}
# bdict['gif'] = True
mk_wav(bdict|{'exp': 2})
mk_wav(bdict|{'tanh': 1.5, 'mid_width_pct': 99})
mk_wav(bdict|{'bezier': 0 })
mk_wav(bdict|{'dline': True })
mk_wt(bdict|{'exp': 2})
mk_wt(bdict|{'tanh': 1.5, 'mid_width_pct': 99})
mk_wt(bdict|{'bezier': 0 })
mk_wt(bdict|{'dline': True })
bdict['shift'] = 64 # h2p has fixed 128 samples
mk_h2p(bdict|{'exp': 2})
mk_h2p(bdict|{'tanh': 1.5, 'mid_width_pct': 99})
mk_h2p(bdict|{'bezier': 0})
mk_h2p(bdict|{'dline': True})
gen_shift()
gen_exp()
gen_direct()
gen_savgol()
gen_gauss()
gen_bitcrush()
gen_bezier()
gen_tanh()