Skip to content

Commit

Permalink
SOUND: Load XACT SoundBank mix bins event parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 5, 2019
1 parent afe2e56 commit 3b4a558
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sound/xactsoundbank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ XACTSoundBank::Event::Event(EventType t) : type(t), timestamp(0) {
params.marker.value = 0;
break;

case kEventTypeMixBins:
for (size_t i = 0; i < ARRAYSIZE(params.mixbins.bins); i++) {
params.mixbins.bins[i].channel = 0;
params.mixbins.bins[i].volume = -64.0f;
}
break;

default:
break;
}
Expand Down
7 changes: 7 additions & 0 deletions src/sound/xactsoundbank.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ class XACTSoundBank {
uint32 value; ///< Custom, user-set value of the marker.
} marker;

struct {
struct {
uint8 channel; ///< Index of the channel to set the volume of.
float volume; ///< Attenuation in dB (-64.0f to 0.0f).
} bins[8];
} mixbins;

} params;

Event(EventType t);
Expand Down
12 changes: 12 additions & 0 deletions src/sound/xactsoundbank_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,18 @@ void XACTSoundBank_Binary::readComplexTrack(Common::SeekableReadStream &xsb, Tra
}
break;

case kEventTypeMixBins:
xsb.skip(2); // Unused

for (size_t j = 0; j < ARRAYSIZE(event.params.mixbins.bins) && parameterSize >= 4; j++, parameterSize -= 4) {
event.params.mixbins.bins[j].channel = xsb.readByte();

xsb.skip(1); // Unknown

event.params.mixbins.bins[j].volume = CLIP(xsb.readSint16LE() / 100.0f, -64.0f, 0.0f);
}
break;

default:
xsb.skip(2); // Unknown
break;
Expand Down

0 comments on commit 3b4a558

Please sign in to comment.