Skip to content

Commit

Permalink
generator: fix positive master volume
Browse files Browse the repository at this point in the history
  • Loading branch information
bnnm committed Jun 27, 2021
1 parent 8adafb4 commit 575c300
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ some extra stuff. If you need help try asking on hcs64.com forums or discord.
that play one or many `.wem` indirectly. You want to open main `.bnk` (leaving
companion `xml` and `txt` files together to get names) with *wwiser*, maybe explore
a bit, and automatically generate *TXTP* for *events*, to use with *vgmstream* to
play music (https://github.com/losnoco/vgmstream).
play music (https://github.com/vgmstream/vgmstream).

Wwise has two "modes", a sound engine that plays single sfx or tracks capable of simple
looping (some games loop like this), and a music engine that dynamically plays multiple
Expand Down
28 changes: 15 additions & 13 deletions wwiser/wtxtp_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def __init__(self, txtp, tree):
self._txtpcache = txtp.txtpcache
self._rebuilder = txtp.rebuilder

self._volume = self._txtpcache.volume_master or 0 #copy since may need to modify
self._volume_master = self._txtpcache.volume_master or 0 #copy since may need to modify

# during write
self._lines = None
Expand Down Expand Up @@ -890,7 +890,7 @@ def _set_selectable(self, node):
def _set_volume(self, node):

# negative volumes are applied per source
if self._volume <= 0:
if self._volume_master <= 0:
return

# find base node and cancel its volume if possible
Expand All @@ -899,8 +899,8 @@ def _set_volume(self, node):
return

if basenode.volume:
basenode.volume += self._volume
self._volume = 0
basenode.volume += self._volume_master
self._volume_master = 0
return

# sometimes we can pass volume to lower leafs if base node didn't have volume and
Expand All @@ -915,11 +915,13 @@ def _set_volume(self, node):
return
subnodes.append(subbasenode)

for subnode in subnodes:
if not subnode.volume:
subnode.volume = 0
subnode.volume += self._volume
self._volume = 0
if subnodes:
for subnode in subnodes:
if not subnode.volume:
subnode.volume = 0
subnode.volume += self._volume_master
# only if there are subnodes to pass info, otherwise it's set at the end
self._volume_master = 0

return

Expand Down Expand Up @@ -1131,8 +1133,8 @@ def _write(self):

# apply increasing master volume after all other volumes
# (lowers chances of clipping due to vgmstream's pcm16)
if self._volume > 0 and not self._simpler:
line = 'commands = #v %sdB' % (self._volume)
if self._volume_master > 0 and not self._simpler:
line = 'commands = #v %sdB' % (self._volume_master)
self._lines.append('%s\n' % (line))

return
Expand Down Expand Up @@ -1354,9 +1356,9 @@ def _write_sound(self, node):
# apply decreasing master volume to wems and mixing with other volumes
# (better performance and lowers chances of clipping due to vgmstream's pcm16)
node_volume = node.volume or 0
if self._volume < 0:
if self._volume_master < 0:
# cancel master dB and node's dB for cleaner results
node_volume += self._volume
node_volume += self._volume_master
if node_volume and not self._simpler:
mods += ' #v %sdB' % (node_volume)

Expand Down
2 changes: 1 addition & 1 deletion wwiser/wversion.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#autogenerated on build
WWISER_VERSION = "v20210526"
WWISER_VERSION = "v20210627"

0 comments on commit 575c300

Please sign in to comment.