Skip to content

Commit

Permalink
add support for loopStart & End in the sformat/ess files. encode_ess …
Browse files Browse the repository at this point in the history
…now has the -l flag for audacity label files, just name the label loop
  • Loading branch information
Tim Blume committed Sep 21, 2023
1 parent 2d9fb4c commit f35d1bf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
{name = "End", email = "[email protected]"},
]
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",
Expand Down
20 changes: 18 additions & 2 deletions src/wgrd_cons_tools/encode_ess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/wgrd_cons_tools/generate_sformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/wgrd_cons_tools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version_string = "0.2.8"
version_string = "0.2.9"

0 comments on commit f35d1bf

Please sign in to comment.