adx: minor updates

This commit is contained in:
louis 2018-05-27 23:02:34 +09:00
parent 754c704d02
commit 9a8bb4f89e
4 changed files with 26 additions and 21 deletions

View file

@ -6,7 +6,7 @@ from .adx_parser import adx_file
def extract_loop_data_from_dir(dir_in, fout):
if fout is None:
fout = "adx_loop.json"
fout = "BgmLoop.json"
files = glob.glob(os.path.join(dir_in, "**/*.adx"), recursive=True)
extract_loop_data_from_files(files, fout)

View file

@ -92,28 +92,28 @@ class adx_file(object):
self.is_valid = 1
def parse_loop_data(self):
if adxf.l_style == 4:
adxf.l_flag = adxf.get_val(LOOP4_FLAG_OFF, LOOP4_FLAG_LEN)
adxf.l_start = adxf.get_val(LOOP4_START_OFF, LOOP4_START_LEN)
adxf.l_end = adxf.get_val(LOOP4_END_OFF, LOOP4_END_LEN)
if not adxf.l_flag:
if self.l_style == 4:
self.l_flag = self.get_val(LOOP4_FLAG_OFF, LOOP4_FLAG_LEN)
self.l_start = self.get_val(LOOP4_START_OFF, LOOP4_START_LEN)
self.l_end = self.get_val(LOOP4_END_OFF, LOOP4_END_LEN)
if not self.l_flag:
return None
if adxf.l_start == 0 and adxf.l_end == adxf.sam_count:
if self.l_start == 0 and self.l_end == self.sam_count:
return None
if adxf.l_start > adxf.sam_count or adxf.l_end > adxf.sam_count:
if self.l_start > self.sam_count or self.l_end > self.sam_count:
raise ValueError("Invalid Loop Data")
return None
if not adxf.l_style in LOOP_TYPE_SUP:
raise NotImplementedError("Loop Style {} Not Implemented".format(str(adxf.l_style)))
if not self.l_style in LOOP_TYPE_SUP:
raise NotImplementedError("Loop Style {} Not Implemented".format(str(self.l_style)))
return None
ret = {}
ret['duration'] = adxf.sam_count / adxf.sam_rate
ret['duration'] = self.sam_count / self.sam_rate
ret['loop_start'] = {}
ret['loop_start']['seconds'] = adxf.l_start / adxf.sam_rate
ret['loop_start']['samples_native'] = adxf.l_start
ret['loop_start']['samples_48k'] = dumb_round(adxf.l_start / adxf.sam_rate * 48000)
ret['loop_start']['seconds'] = self.l_start / self.sam_rate
ret['loop_start']['samples_native'] = self.l_start
ret['loop_start']['samples_48k'] = dumb_round(self.l_start / self.sam_rate * 48000)
ret['loop_end'] = {}
ret['loop_end']['seconds'] = adxf.l_end / adxf.sam_rate
ret['loop_end']['samples_native'] = adxf.l_end
ret['loop_end']['samples_48k'] = dumb_round(adxf.l_end / adxf.sam_rate * 48000)
ret['loop_end']['seconds'] = self.l_end / self.sam_rate
ret['loop_end']['samples_native'] = self.l_end
ret['loop_end']['samples_48k'] = dumb_round(self.l_end / self.sam_rate * 48000)
return ret