Skip to content

Commit

Permalink
SOUND: Load XACT Sound pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Dec 30, 2018
1 parent 3ab178c commit 110ff37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/sound/xactsoundbank.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,14 @@ class XACTSoundBank {
uint8 categoryIndex; ///< Index of the category.

float volume; ///< Volume attenuation in dB. 0.0f means full volume, -64.0f is maximum attenuation.
float pitch; ///< Pitch change in semitones.

uint8 layer;
uint8 priority;

Tracks tracks; ///< All the tracks in the sound.

Sound() : categoryIndex(kCategoryNone), volume(0.0f),
Sound() : categoryIndex(kCategoryNone), volume(0.0f), pitch(0.0f),
layer(kLayerNone), priority(255) {
}
};
Expand Down
3 changes: 3 additions & 0 deletions src/sound/xactsoundbank_ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ void XACTSoundBank_ASCII::load(Common::SeekableReadStream &xsb) {
if (tokens.size() > 5)
sound->volume = CLIP((getNumber(tokens[4]) + getNumber(tokens[5])) / 100.0f, -64.0f, 0.0f);

if (tokens.size() > 6)
sound->pitch = CLIP(getNumber(tokens[6]) / 100.0f, -24.0f, 24.0f);

if (tokens.size() > 7) {
const int64 priority = getNumber(tokens[7]);
if (priority > 0)
Expand Down
6 changes: 3 additions & 3 deletions src/sound/xactsoundbank_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ void XACTSoundBank_Binary::readSounds(Common::SeekableReadStream &xsb, uint32 of
const uint32 indicesOrOffset = xsb.readUint32LE();

const uint16 volume = xsb.readUint16LE();
const uint16 pitch = xsb.readUint16LE();
sound.volume = -((int16) (volume & 0x1FF)) * 0.16f;

const uint8 trackCount = xsb.readByte();
sound.pitch = CLIP((xsb.readSint16LE() * 12) / 4096.0f, -24.0f, 24.0f);

sound.volume = (volume & 0x1FF) * -0.16f;
const uint8 trackCount = xsb.readByte();

sound.layer = xsb.readByte();
sound.categoryIndex = xsb.readByte();
Expand Down

0 comments on commit 110ff37

Please sign in to comment.