libctru  v2.4.1
Data Structures | Macros
ndsp.h File Reference

Interface for Nintendo's default DSP component. More...

#include <3ds/os.h>

Go to the source code of this file.

Data Structures

struct  ndspAdpcmData
 ADPCM data. More...
 
struct  ndspWaveBuf
 Wave buffer struct. More...
 

Macros

#define NDSP_SAMPLE_RATE   (SYSCLOCK_SOC / 512.0)
 

Functions

Initialization and basic operations
void ndspUseComponent (const void *binary, u32 size, u16 progMask, u16 dataMask)
 Sets up the DSP component. More...
 
Result ndspInit (void)
 Initializes NDSP.
 
void ndspExit (void)
 Exits NDSP.
 
u32 ndspGetDroppedFrames (void)
 Gets the number of dropped sound frames. More...
 
u32 ndspGetFrameCount (void)
 Gets the total sound frame count. More...
 
General parameters
void ndspSetMasterVol (float volume)
 Sets the master volume. More...
 
float ndspGetMasterVol (void)
 Gets the master volume. More...
 
void ndspSetOutputMode (ndspOutputMode mode)
 Sets the output mode. More...
 
ndspOutputMode ndspGetOutputMode (void)
 Gets the output mode. More...
 
void ndspSetClippingMode (ndspClippingMode mode)
 Sets the clipping mode. More...
 
ndspClippingMode ndspGetClippingMode (void)
 Gets the clipping mode. More...
 
void ndspSetOutputCount (int count)
 Sets the output count. More...
 
int ndspGetOutputCount (void)
 Gets the output count. More...
 
void ndspSetCapture (ndspWaveBuf *capture)
 Sets the wave buffer to capture audio to. More...
 
void ndspSetCallback (ndspCallback callback, void *data)
 Sets the sound frame callback. More...
 
Surround
void ndspSurroundSetDepth (u16 depth)
 Sets the surround sound depth. More...
 
u16 ndspSurroundGetDepth (void)
 Gets the surround sound depth. More...
 
void ndspSurroundSetPos (ndspSpeakerPos pos)
 Sets the surround sound position. More...
 
ndspSpeakerPos ndspSurroundGetPos (void)
 Gets the surround sound position. More...
 
void ndspSurroundSetRearRatio (u16 ratio)
 Sets the surround sound rear ratio. More...
 
u16 ndspSurroundGetRearRatio (void)
 Gets the surround sound rear ratio. More...
 
Auxiliary output
void ndspAuxSetEnable (int id, bool enable)
 Configures whether an auxiliary output is enabled. More...
 
bool ndspAuxIsEnabled (int id)
 Gets whether auxiliary output is enabled. More...
 
void ndspAuxSetFrontBypass (int id, bool bypass)
 Configures whether an auxiliary output should use front bypass. More...
 
bool ndspAuxGetFrontBypass (int id)
 Gets whether auxiliary output front bypass is enabled. More...
 
void ndspAuxSetVolume (int id, float volume)
 Sets the volume of an auxiliary output. More...
 
float ndspAuxGetVolume (int id)
 Gets the volume of an auxiliary output. More...
 
void ndspAuxSetCallback (int id, ndspAuxCallback callback, void *data)
 Sets the callback of an auxiliary output. More...
 

Data types

Sound output modes.

enum  ndspOutputMode {
  NDSP_OUTPUT_MONO = 0 ,
  NDSP_OUTPUT_STEREO = 1 ,
  NDSP_OUTPUT_SURROUND = 2
}
 
enum  ndspClippingMode {
  NDSP_CLIP_NORMAL = 0 ,
  NDSP_CLIP_SOFT = 1
}
 
enum  ndspSpeakerPos {
  NDSP_SPKPOS_SQUARE = 0 ,
  NDSP_SPKPOS_WIDE = 1 ,
  NDSP_SPKPOS_NUM = 2
}
 
enum  {
  NDSP_WBUF_FREE = 0 ,
  NDSP_WBUF_QUEUED = 1 ,
  NDSP_WBUF_PLAYING = 2 ,
  NDSP_WBUF_DONE = 3
}
 Wave buffer status. More...
 
typedef void(* ndspCallback) (void *data)
 Sound frame callback function. (data = User provided data)
 
typedef void(* ndspAuxCallback) (void *data, int nsamples, void *samples[4])
 Auxiliary output callback function. (data = User provided data, nsamples = Number of samples, samples = Sample data)
 

Detailed Description

Interface for Nintendo's default DSP component.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Wave buffer status.

Enumerator
NDSP_WBUF_FREE 

The wave buffer is not queued.

NDSP_WBUF_QUEUED 

The wave buffer is queued and has not been played yet.

NDSP_WBUF_PLAYING 

The wave buffer is playing right now.

NDSP_WBUF_DONE 

The wave buffer has finished being played.

◆ ndspClippingMode

Enumerator
NDSP_CLIP_NORMAL 

"Normal" clipping mode (?)

NDSP_CLIP_SOFT 

"Soft" clipping mode (?)

◆ ndspOutputMode

Enumerator
NDSP_OUTPUT_MONO 

Mono sound.

NDSP_OUTPUT_STEREO 

Stereo sound.

NDSP_OUTPUT_SURROUND 

3D Surround sound

◆ ndspSpeakerPos

Enumerator
NDSP_SPKPOS_SQUARE 

?

NDSP_SPKPOS_WIDE 

?

NDSP_SPKPOS_NUM 

?

Function Documentation

◆ ndspAuxGetFrontBypass()

bool ndspAuxGetFrontBypass ( int  id)

Gets whether auxiliary output front bypass is enabled.

Parameters
idID of the auxiliary output.
Returns
Whether auxiliary output front bypass is enabled.

◆ ndspAuxGetVolume()

float ndspAuxGetVolume ( int  id)

Gets the volume of an auxiliary output.

Parameters
idID of the auxiliary output.
Returns
Volume of the auxiliary output.

◆ ndspAuxIsEnabled()

bool ndspAuxIsEnabled ( int  id)

Gets whether auxiliary output is enabled.

Parameters
idID of the auxiliary output.
Returns
Whether auxiliary output is enabled.

◆ ndspAuxSetCallback()

void ndspAuxSetCallback ( int  id,
ndspAuxCallback  callback,
void *  data 
)

Sets the callback of an auxiliary output.

Parameters
idID of the auxiliary output.
callbackCallback to set.
dataUser-defined data to pass to the callback.

◆ ndspAuxSetEnable()

void ndspAuxSetEnable ( int  id,
bool  enable 
)

Configures whether an auxiliary output is enabled.

Parameters
idID of the auxiliary output.
enableWhether to enable the auxiliary output.

◆ ndspAuxSetFrontBypass()

void ndspAuxSetFrontBypass ( int  id,
bool  bypass 
)

Configures whether an auxiliary output should use front bypass.

Parameters
idID of the auxiliary output.
bypassWhether to use front bypass.

◆ ndspAuxSetVolume()

void ndspAuxSetVolume ( int  id,
float  volume 
)

Sets the volume of an auxiliary output.

Parameters
idID of the auxiliary output.
volumeVolume to set.

◆ ndspGetClippingMode()

ndspClippingMode ndspGetClippingMode ( void  )

Gets the clipping mode.

Returns
The clipping mode.

◆ ndspGetDroppedFrames()

u32 ndspGetDroppedFrames ( void  )

Gets the number of dropped sound frames.

Returns
The number of dropped sound frames.

◆ ndspGetFrameCount()

u32 ndspGetFrameCount ( void  )

Gets the total sound frame count.

Returns
The total sound frame count.

◆ ndspGetMasterVol()

float ndspGetMasterVol ( void  )

Gets the master volume.

Returns
The master volume.

◆ ndspGetOutputCount()

int ndspGetOutputCount ( void  )

Gets the output count.

Returns
The output count.

◆ ndspGetOutputMode()

ndspOutputMode ndspGetOutputMode ( void  )

Gets the output mode.

Returns
The output mode.

◆ ndspSetCallback()

void ndspSetCallback ( ndspCallback  callback,
void *  data 
)

Sets the sound frame callback.

Parameters
callbackCallback to set.
dataUser-defined data to pass to the callback.

◆ ndspSetCapture()

void ndspSetCapture ( ndspWaveBuf *  capture)

Sets the wave buffer to capture audio to.

Parameters
captureWave buffer to capture to.

◆ ndspSetClippingMode()

void ndspSetClippingMode ( ndspClippingMode  mode)

Sets the clipping mode.

Parameters
modeClipping mode to set. Defaults to NDSP_CLIP_SOFT.

◆ ndspSetMasterVol()

void ndspSetMasterVol ( float  volume)

Sets the master volume.

Parameters
volumeVolume to set. Defaults to 1.0f.

◆ ndspSetOutputCount()

void ndspSetOutputCount ( int  count)

Sets the output count.

Parameters
countOutput count to set. Defaults to 2.

◆ ndspSetOutputMode()

void ndspSetOutputMode ( ndspOutputMode  mode)

Sets the output mode.

Parameters
modeOutput mode to set. Defaults to NDSP_OUTPUT_STEREO.
Examples
audio/filters/source/main.c, and audio/streaming/source/main.c.

◆ ndspSurroundGetDepth()

u16 ndspSurroundGetDepth ( void  )

Gets the surround sound depth.

Returns
The surround sound depth.

◆ ndspSurroundGetPos()

ndspSpeakerPos ndspSurroundGetPos ( void  )

Gets the surround sound position.

Returns
The surround sound speaker position.

◆ ndspSurroundGetRearRatio()

u16 ndspSurroundGetRearRatio ( void  )

Gets the surround sound rear ratio.

Returns
The rear ratio.

◆ ndspSurroundSetDepth()

void ndspSurroundSetDepth ( u16  depth)

Sets the surround sound depth.

Parameters
depthDepth to set. Defaults to 0x7FFF.

◆ ndspSurroundSetPos()

void ndspSurroundSetPos ( ndspSpeakerPos  pos)

Sets the surround sound position.

Parameters
posPosition to set. Defaults to NDSP_SPKPOS_SQUARE.

◆ ndspSurroundSetRearRatio()

void ndspSurroundSetRearRatio ( u16  ratio)

Sets the surround sound rear ratio.

Parameters
ratioRear ratio to set. Defaults to 0x8000.

◆ ndspUseComponent()

void ndspUseComponent ( const void *  binary,
u32  size,
u16  progMask,
u16  dataMask 
)

Sets up the DSP component.

Parameters
binaryDSP binary to load.
sizeSize of the DSP binary.
progMaskProgram RAM block mask to load the binary to.
dataMaskData RAM block mask to load the binary to.