adx: minor updates
This commit is contained in:
parent
754c704d02
commit
9a8bb4f89e
4 changed files with 26 additions and 21 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.swp
|
||||
virtualenv/
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ def main():
|
|||
parser_adx_loop = parser_adx_subparsers.add_parser("loop", help="Extract loop data")
|
||||
parser_adx_loop.add_argument("--output", "-o",
|
||||
help="JSON output file for loop data",
|
||||
type=str, dest="adx_json_out")
|
||||
parser_adx_loop.add_argument("--input", "-i",
|
||||
type=str, dest="JSON_OUT")
|
||||
parser_adx_loop.add_argument("ADX_DIR",
|
||||
help="Input directory containing ADX files",
|
||||
type=str, dest="adx_dir_in", required=True)
|
||||
type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == "adx":
|
||||
if args.subcommand == "loop":
|
||||
adx.extract_loop_data_from_dir(args.adx_dir_in, args.adx_json_out)
|
||||
adx.extract_loop_data_from_dir(args.ADX_DIR, args.JSON_OUT)
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue