ndspy.soundWaveArchive: Sound Wave Archives

The ndspy.soundWaveArchive module lets you edit and create SWAR files, which are essentially just slightly glorified lists of SWAV files.

See also

If you aren’t familiar with how SDAT files are structured, consider reading the appendix explaining this.

Documentation about the SWAV files within SWARs can be found on the ndspy.soundWave: Sound Waves page.

class ndspy.soundWaveArchive.SWAR([file[, unk02]])

A SWAR sound wave archive.

Parameters:
  • file (bytes) – The data to be read as a SWAR file. If this is not provided, the SWAR object will initially be empty.

  • unk02 – The initial value for the unk02 attribute.

dataMergeOptimizationID

When saving a SDAT file containing multiple SWAR files, ndspy will check if any of them save to identical data. If it finds any, it will only encode the data for them once and then reference it multiple times, to save some space. This attribute is an extra field that is also compared between SWAR files, which you can use to exclude particular ones from this optimization.

Since this defaults to 0 for all SWARs created from scratch, this optimization will happen by default. It’s unlikely that you will need to use this attribute to disable the optimization, but you can.

Note

This value is not explicitly saved in the SWAR file or in the SDAT file containing it.

Type:

int

Default:

0

unk02

The value following the SWAR’s file ID in the “INFO” section of the SDAT file it is contained in. Its purpose is unknown.

Note

This value is not explicitly saved in the SWAR file, but it is saved in the SDAT file if the SWAR is within one.

Type:

int

Default:

0

waves

The SWAV objects contained in this SWAR. “Wave IDs” or “SWAV IDs” are simply indices into this list.

Type:

list of ndspy.soundWave.SWAV

Default:

[]

classmethod fromWaves(waves[, unk02])

Create a SWAR from a list of SWAVs.

Parameters:
  • waves – The initial value for the waves attribute.

  • unk02 – The initial value for the unk02 attribute.

Returns:

The SWAR object.

Return type:

SWAR

classmethod fromFile(filePath[, unk02])

Load a SWAR from a filesystem file. This is a convenience function.

Parameters:
  • filePath (str or other path-like object) – The path to the SWAR file to open.

  • unk02 – The initial value for the unk02 attribute.

Returns:

The SWAR object.

Return type:

SWAR

save()

Generate file data representing this SWAR, and then return that data and unk02 as a pair (2-tuple). This matches the parameters of the default class constructor.

Returns:

The SWAR file data and unk02.

Return type:

(data, unk02), where data is of type bytes and unk02 is of type int

saveToFile(filePath)

Generate file data representing this SWAR, and save it to a filesystem file. This is a convenience function.

Parameters:

filePath (str or other path-like object) – The path to the SWAR file to save to.