-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilewrite.py
More file actions
executable file
·46 lines (34 loc) · 1.58 KB
/
filewrite.py
File metadata and controls
executable file
·46 lines (34 loc) · 1.58 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
# loosely inspired from the parammanager
# Takes a file name and path and returns a full path to file.
import os
class fileHandler():
def __init__(self) :
self.fname=""
self.outpath = ""
'''make file name from soundname, paramNames, param values, chunk number, example number'''
def makeName(self, soundName, paramArr, enumP, chunk, examples=1, x=1):
'''Construct filenames with static parameters'''
self.fname = soundName
# for paramNum in range(len(fixedParams)):
# self.fname = self.fname + '--' + fixedParams[paramNum]['synth_pname'] + '-'+'{:05.2f}'.format(fixedParams[paramNum]["synth_val"])
for paramNum in range(len(paramArr)):
self.fname = self.fname + '--' + paramArr[paramNum]['user_pname'] + '-'+'{:05.2f}'.format(enumP[paramNum])
if chunk != None:
self.fname = self.fname + '--c-'+'{:02}'.format(chunk)
if examples > 1:
self.fname = self.fname + '--x-'+'{:02}'.format(x)
return self.fname
def getFileName(self):
return self.fname
def getFullPath(self):
return self.outpath
# only store the actual value, not the normed value used for setting
def makeFullPath(self, outpath, name, ext) :
if os.path.isdir(outpath):
self.outpath = outpath
else:
self.outpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), outpath)
if not os.path.isdir(self.outpath):
os.mkdir(self.outpath)
fullpath = os.path.join(outpath, name + ext)
return fullpath