Skip to content

Commit

Permalink
SOUND: Load XACT SoundBank pitch/filter envelope event parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 1, 2019
1 parent e7900e6 commit afe2e56
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sound/xactsoundbank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ XACTSoundBank::Event::Event(EventType t) : type(t), timestamp(0) {
params.aeg.sustain = 0.0f;
break;

case kEventTypeEnvelopePitch:
params.pfeg.delay = 0;
params.pfeg.attack = 0;
params.pfeg.hold = 0;
params.pfeg.decay = 0;
params.pfeg.release = 0;

params.pfeg.sustain = 0.0f;

params.pfeg.pitch = 0.0f;
params.pfeg.filter = 0.0f;
break;

case kEventTypeLoop:
params.loop.count = 0;
break;
Expand Down
13 changes: 13 additions & 0 deletions src/sound/xactsoundbank.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ class XACTSoundBank {
float sustain; ///< Sustain power in fractions (0.0f to 1.0f).
} aeg;

struct {
uint32 delay; ///< Delay length in milliseconds.
uint32 attack; ///< Attack length in milliseconds.
uint32 hold; ///< Hold length in milliseconds.
uint32 decay; ///< Deay length in milliseconds.
uint32 release; ///< Release length in milliseconds.

float sustain; ///< Sustain power in fractions (0.0f to 1.0f).

float pitch; ///< Pitch scale in semitones (-12.0 to 12.0f).
float filter; ///< Filter cut-off in semitones (-96.0 to 96.0f).
} pfeg;

struct {
uint16 count;
} loop;
Expand Down
21 changes: 21 additions & 0 deletions src/sound/xactsoundbank_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,27 @@ void XACTSoundBank_Binary::readComplexTrack(Common::SeekableReadStream &xsb, Tra
}
break;

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

if (parameterSize >= 16) {
event.params.pfeg.delay = (xsb.readUint16LE() * 43680) / 4095;
event.params.pfeg.attack = (xsb.readUint16LE() * 43680) / 4095;
event.params.pfeg.hold = (xsb.readUint16LE() * 43680) / 4095;
event.params.pfeg.decay = (xsb.readUint16LE() * 43680) / 4095;
event.params.pfeg.release = (xsb.readUint16LE() * 43680) / 4095;

event.params.pfeg.sustain = xsb.readByte() / 255.0f;

xsb.skip(3); // Unknown

event.params.pfeg.pitch = xsb.readSByte() * 12.0f / 128.0f;
event.params.pfeg.filter = xsb.readSByte() * 96.0f / 128.0f;

parameterSize -= 16;
}
break;

case kEventTypeLoop:
event.params.loop.count = xsb.readUint16LE();
break;
Expand Down

0 comments on commit afe2e56

Please sign in to comment.