diff --git a/pyproject.toml b/pyproject.toml index 55af706..dd1a1f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = [ {name = "End", email = "wgrd@3nd.io"}, ] description="Tools for working with the xml files generated by wgrd_cons_parsers for modding the game Wargame: Red Dragon." -version = "0.2.8" +version = "0.2.9" requires-python = ">=3.10" dependencies = [ "dingsda", diff --git a/src/wgrd_cons_tools/encode_ess.py b/src/wgrd_cons_tools/encode_ess.py index a2730fb..34d3558 100755 --- a/src/wgrd_cons_tools/encode_ess.py +++ b/src/wgrd_cons_tools/encode_ess.py @@ -185,6 +185,7 @@ def bitsToBytes(list): if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("path", type=pathlib.Path, help="path to the wave file") + parser.add_argument("-l", "--labels", type=pathlib.Path, help="path to the audacity labels file") parser.add_argument("-o", "--output", type=pathlib.Path, default="test.ess", help="path to the output ess file") args = parser.parse_args() @@ -227,8 +228,23 @@ def bitsToBytes(list): write8(fo, channelCount) write16b(fo, samplerate) write32b(fo, frameCount) - write32b(fo, 0) - write32b(fo, frameCount) + + # loop start and end + if not args.labels: + write32b(fo, 0) + write32b(fo, frameCount) + else: + labels = open(args.labels, "r").readlines() + for label in labels: + start, end, name = label.split("\t") + if name == "loop": + start = float(start) * samplerate + end = float(end) * samplerate + + write32b(fo, int(start)) + write32b(fo, int(end)) + else: + print("Skipping label '%s'" % name) # Calculate number of blocks blockCount = (frameCount + (blockMaxFrameCount - 1)) // blockMaxFrameCount diff --git a/src/wgrd_cons_tools/generate_sformat.py b/src/wgrd_cons_tools/generate_sformat.py index 5068c2b..255d153 100644 --- a/src/wgrd_cons_tools/generate_sformat.py +++ b/src/wgrd_cons_tools/generate_sformat.py @@ -23,13 +23,13 @@ unk0=0x6, isShort="true", channelCount=ess_header.channels, - unk3=ess_header.channels*0x200, + frameSize=ess_header.channels*0x200, samplerate=ess_header.samplerate, frameCount=ess_header.frameCount, unk4=2, essLength=len(essdata), - essUnk2=0, - frameCount2=ess_header.frameCount, + loopStart=ess_header.loopStart, + loopEnd=ess_header.loopEnd, data=None) sformatdata = SFormat.build(sformat) diff --git a/src/wgrd_cons_tools/version.py b/src/wgrd_cons_tools/version.py index 9fc795a..fe0ee7a 100644 --- a/src/wgrd_cons_tools/version.py +++ b/src/wgrd_cons_tools/version.py @@ -1 +1 @@ -version_string = "0.2.8" +version_string = "0.2.9"