ndspy.soundArchive: SDAT (Sound Archives)

ndspy.soundArchive allows you to load and save SDAT sound archive files and the files within them.

See also

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

class ndspy.soundArchive.SDAT([data])

A sound data archive file (SDAT).

Parameters:

data (bytes) – The data to be read as an SDAT file. If not provided, the SDAT will use default values.

banks

The instrument banks in this SDAT, in the form of a list of name-value pairs containing ndspy.soundBank.SBNK instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, bank), where name is of type str or None, and bank is of type ndspy.soundBank.SBNK or None

Default:

[]

groups

The file groups in this SDAT, in the form of a list of name-value pairs, where the values are lists containing ndspy.soundGroup.GroupEntry instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, entries), where name is of type str or None, and entries is None or a list of ndspy.soundGroup.GroupEntrys

Default:

[]

sequenceArchives

The sound-effect sequence archives in this SDAT, in the form of a list of name-value pairs containing ndspy.soundSequenceArchive.SSAR instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, sequenceArchive), where name is of type str or None, and sequenceArchive is of type ndspy.soundSequenceArchive.SSAR or None

Default:

[]

sequencePlayers

The sequence players in this SDAT, in the form of a list of name-value pairs containing ndspy.soundSequencePlayer.SequencePlayer instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, sequencePlayer), where name is of type str or None, and sequencePlayer is of type ndspy.soundSequencePlayer.SequencePlayer or None

Default:

[]

sequences

The sequenced music pieces in this SDAT, in the form of a list of name-value pairs containing ndspy.soundSequence.SSEQ instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, sequence), where name is of type str or None, and sequence is of type ndspy.soundSequence.SSEQ or None

Default:

[]

streamPlayers

The stream players in this SDAT, in the form of a list of name-value pairs containing ndspy.soundStreamPlayer.StreamPlayer instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, streamPlayer), where name is of type str or None, and streamPlayer is of type ndspy.soundStreamPlayer.StreamPlayer or None

Default:

[]

streams

The streamed music pieces in this SDAT, in the form of a list of name-value pairs containing ndspy.soundStream.STRM instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, stream), where name is of type str or None, and stream is of type ndspy.soundStream.STRM or None

Default:

[]

waveArchives

The archive files containing wave files in this SDAT, in the form of a list of name-value pairs containing ndspy.soundWaveArchive.SWAR instances.

This is presented as a list of name-value pairs because collections.OrderedDict – the best choice for an order-preserving dictionary type – does not provide an easy way to adjust the order of its elements.

See also

ndspy.indexInNamedList(), ndspy.findInNamedList(), ndspy.setInNamedList() – helper functions you can use to find and replace values in this list.

Type:

list of (name, waveArchive), where name is of type str or None, and waveArchive is of type ndspy.soundWaveArchive.SWAR or None

Default:

[]

fatLengthsIncludePadding

If this is True, files within this SDAT will be extended with null bytes to provide the proper alignment. If this is False, null bytes for alignment will still be present, but they will be between files rather than appended to the previous file.

This is chosen heuristically when loading an SDAT, so it may not always be accurate. If this value matters to you, it’s a good idea to explicitly set it to the value you want before saving.

Type:

bool

Default:

False

fileAlignment

The alignment of files within this SDAT. Null bytes will be placed between files in order to ensure that all files begin at an offset in the ROM data that is a multiple of this value.

This is chosen heuristically when loading an SDAT, so it may not always be accurate. If this value matters to you, it’s a good idea to explicitly set it to the value you want before saving.

See also

firstFileAlignment – the alignment of the first file, which may differ from this value.

fatLengthsIncludePadding – whether the padding used to align files should be included in the file lengths or not.

Type:

int

Default:

0x20

firstFileAlignment

The alignment of the first file within this SDAT. If this is None, the alignment will be the same as for other files.

This is chosen heuristically when loading an SDAT, so it may not always be accurate. If this value matters to you, it’s a good idea to explicitly set it to the value you want before saving.

See also

fileAlignment – the alignment of all other files.

Type:

int or None

Default:

None

padAtEnd

If this is True, alignment padding will be added at the very end of the SDAT (after the last file) or not. This is fairly pointless, but most SDAT files do this. Only SDAT files from modified games seem to not do this.

This is chosen heuristically when loading an SDAT, so it may not always be accurate. If this value matters to you, it’s a good idea to explicitly set it to the value you want before saving.

See also

fatLengthsIncludePadding – whether the padding used to align files should be included in the file lengths or not.

Type:

bool

Default:

True

padSymbSizeTo4InSDATHeader

If this is True, the alignment padding at the end of the “SYMB” block will be included in its length. Only SDAT files from modified games seem to do this.

This is chosen heuristically when loading an SDAT, so it may not always be accurate. If this value matters to you, it’s a good idea to explicitly set it to the value you want before saving.

Type:

bool

Default:

False

classmethod fromFile(filePath)

Load an SDAT from a filesystem file. This is a convenience function.

Parameters:

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

Returns:

The SDAT object.

Return type:

SDAT

save()

Generate file data representing this SDAT.

Returns:

The SDAT file data.

Return type:

bytes

saveToFile(filePath)

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

Parameters:

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