ndspy: General

The ndspy namespace contains functions and classes that don’t need their own modules.

ndspy.VERSION

A collections.namedtuple() that provides the current ndspy version. You can use this like a 3-tuple (so, for example, this would behave like (2, 0, 0) for ndspy 2.0.0) or like an object with major, minor and patch integer attributes.

Note

This was added in ndspy 2.0.0, so it doesn’t exist in 1.0.0 and 1.0.1. However, 2.0.0 was released less than a week after 1.0.0, so it wouldn’t be too unsafe to just assume this probably exists.

class ndspy.Processor
Base class:

enum.IntEnum

An enumeration that distinguishes between the Nintendo DS’s two processors.

ARM9

Value 9: the ARM9 processor. This is the main processor used by the DS.

ARM7

Value 7: the ARM7 processor. This is used for less-important tasks, and to play GBA games.

class ndspy.WaveType
Base class:

enum.IntEnum

An enumeration that distinguishes between the three types of wave data that the Nintendo DS sound hardware understands.

PCM8

Value 0: signed 8-bit PCM wave data. One byte per sample, with 0 being the center line.

PCM16

Value 1: signed 16-bit little-endian PCM wave data. Two bytes per sample, with 0 being the center line.

ADPCM

Value 2: little-endian IMA-ADPCM wave data. This is the most complicated format of the three, but it stores about two samples per byte, so it’s the most space-efficient choice.

See also

More information about IMA-ADPCM, including the quirks of how it’s implemented on a DS, can be found at GBATEK.

More information about IMA-ADPCM in general is available at MultimediaWiki.

ndspy.findInNamedList(L, name)

Find the value of the item with a particular name in a list containing name-value pairs.

Such a list looks like the following:

[(name1, entry1), (name2, entry2), (name3, entry3), ...]

Names are usually strs, but not always.

See also

indexInNamedList() – to retrieve the index of the entry instead of its value.

setInNamedList() – to replace the value of the entry with a new one.

Parameters:
  • L

    The list to search in.

    type:

    list of (name, entry) where name is typically of type str and entry is of any type

  • name

    The name to look for.

    type:

    usually str

Returns:

The value of the list entry with the specified name; that is, the second item in that pair.

Return type:

Whatever type the value in the name-value pair has.

Raises:

KeyError – if there is no list item with that name

ndspy.indexInNamedList(L, name)

Find the index of the item with a particular name in a list containing name-value pairs.

Such a list looks like the following:

[(name1, entry1), (name2, entry2), (name3, entry3), ...]

Names are usually strs, but not always.

See also

findInNamedList() – to retrieve the value of the entry instead of its index.

setInNamedList() – to replace the value of the entry with a new one.

Parameters:
  • L

    The list to search in.

    type:

    list of (name, entry) where name is typically of type str and entry is of any type

  • name

    The name to look for.

    type:

    usually str

Returns:

The index of the list entry with the specified name.

Return type:

int

Raises:

KeyError – if there is no list item with that name

ndspy.setInNamedList(L, name, value)

Find the item with a particular name in a list containing name-value pairs, and replace its value with a new one. The previous value is discarded.

Such a list looks like the following:

[(name1, entry1), (name2, entry2), (name3, entry3), ...]

Names are usually strs, but not always.

See also

findInNamedList() – to retrieve the value of the entry instead of replacing it.

indexInNamedList() – to retrieve the index of the entry instead of replacing it.

Parameters:
  • L

    The list to search in.

    type:

    list of (name, entry) where name is typically of type str and entry is of any type

  • name

    The name to look for.

    type:

    usually str

  • value

    The new value that the existing value in the list should be replaced with.

    type:

    Any type.

Raises:

KeyError – if there is no list item with that name