NDSP_FRONT_BYPASS = BIT(4), ///< Front bypass.
NDSP_3D_SURROUND_PREPROCESSED = BIT(6), ///< (?) Unknown, under research
};
+
+/// Interpolation types.
+enum
+{
+ NDSP_INTERP_POLYPHASE = 0, ///< Polyphase interpolation
+ NDSP_INTERP_LINEAR = 1, ///< Linear interpolation
+ NDSP_INTERP_NONE = 2, ///< No interpolation
+};
+
///@}
///@name Basic channel operation
///@name IIR filters
///@{
/**
- * @brief Configures whether the IIR mono filter of a channel is enabled.
+ * @brief Configures whether the IIR monopole filter of a channel is enabled.
* @param id ID of the channel (0..23).
- * @param enable Whether to enable the IIR mono filter.
+ * @param enable Whether to enable the IIR monopole filter.
*/
void ndspChnIirMonoSetEnable(int id, bool enable);
// ndspChnIirMonoSetParams
///@name Data types
///@{
+/// Sound output modes.
+enum
+{
+ NDSP_OUTPUT_MONO = 0, ///< Mono sound
+ NDSP_OUTPUT_STEREO = 1, ///< Stereo sound
+ NDSP_OUTPUT_SURROUND = 2, ///< 3D Surround sound
+};
+
+// Clipping modes.
+enum
+{
+ NDSP_CLIP_NORMAL = 0, ///< "Normal" clipping mode (?)
+ NDSP_CLIP_SOFT = 1, ///< "Soft" clipping mode (?)
+};
+
+// Surround speaker positions.
+enum
+{
+ NDSP_SPKPOS_SQUARE = 0, ///<?
+ NDSP_SPKPOS_WIDE = 1, ///<?
+ NDSP_SPKPOS_NUM = 2, ///<?
+};
+
/// ADPCM data.
typedef struct
{
/// Wave buffer type.
typedef struct tag_ndspWaveBuf ndspWaveBuf;
+/// Wave buffer status.
+enum
+{
+ NDSP_WBUF_FREE = 0, ///< The wave buffer is not queued.
+ NDSP_WBUF_QUEUED = 1, ///< The wave buffer is queued and has not been played yet.
+ NDSP_WBUF_PLAYING = 2, ///< The wave buffer is playing right now.
+ NDSP_WBUF_DONE = 3, ///< The wave buffer has finished being played.
+};
+
/// Wave buffer struct.
struct tag_ndspWaveBuf
{
u32 offset; ///< Buffer offset. Only used for capture.
bool looping; ///< Whether to loop the buffer.
- u8 padding; ///< Padding.
+ u8 status; ///< Queuing/playback status.
u16 sequence_id; ///< Sequence ID. Assigned automatically by ndspChnWaveBufAdd.
ndspWaveBuf* next; ///< Next buffer to play. Used internally, do not modify.
/**
* @brief Sets the output mode.
- * @param mode Output mode to set. Defaults to 0.
+ * @param mode Output mode to set. Defaults to NDSP_OUTPUT_STEREO.
*/
void ndspSetOutputMode(int mode);
/**
* @brief Sets the clipping mode.
- * @param mode Clipping mode to set. Defaults to 1.
+ * @param mode Clipping mode to set. Defaults to NDSP_CLIP_SOFT.
*/
void ndspSetClippingMode(int mode);
/**
* @brief Sets the surround sound position.
- * @param pos Position to set. Defaults to 0.
+ * @param pos Position to set. Defaults to NDSP_SPKPOS_SQUARE.
*/
void ndspSurroundSetPos(u16 pos);
if (!buf->nsamples) return;
buf->next = NULL;
+ buf->status = NDSP_WBUF_QUEUED;
LightLock_Lock(&chn->lock);
if (cb)
if (flags & CFLAG_INTERPTYPE)
{
st->rim[0] = chn->interpType;
- if (chn->interpType == 0)
+ if (chn->interpType == NDSP_INTERP_POLYPHASE)
{
if (chn->rate <= 1.0f)
- st->rim[1] = 2;
+ st->rim[1] = NDSP_INTERP_NONE;
else if (chn->rate <= (4.0f/3))
- st->rim[1] = 1;
+ st->rim[1] = NDSP_INTERP_LINEAR;
else
- st->rim[1] = 0;
+ st->rim[1] = NDSP_INTERP_POLYPHASE;
} else
- st->rim[1] = 1;
+ st->rim[1] = NDSP_INTERP_LINEAR;
stflags |= 0x20000;
}
if (chn->wavBufCount == 0)
{
// This is the first buffer - set it up
+ wb->status = NDSP_WBUF_PLAYING;
chn->wavBufIdNext = 0;
st->seqId = wb->sequence_id;
st->sampleCount = ndspiRotateVal(wb->nsamples);
{
u16 seqId = st->curSeqId;
ndspWaveBuf* wb = chn->waveBuf;
- chn->waveBufSeqPos = seqId;
chn->samplePos = ndspiRotateVal(st->samplePos);
if ((st->flags & 0xFF00) && wb)
{
chn->wavBufCount--;
bool shouldBreak = seqId == 0 && (wb->sequence_id == st->lastSeqId || st->lastSeqId == 0);
+ wb->status = NDSP_WBUF_DONE;
wb = wb->next;
if (!wb || shouldBreak || chn->wavBufCount == 0)
break;
}
+ if (wb && wb->status != NDSP_WBUF_DONE)
+ wb->status = NDSP_WBUF_PLAYING;
if (seqId == 0)
chn->wavBufCount = 0;
chn->waveBuf = wb;
+ chn->waveBufSeqPos = seqId;
LightLock_Unlock(&chn->lock);
}
+
}
chn->playing = (st->flags & 0xFF) ? true : false;
}
memset(&ndspMaster, 0, sizeof(ndspMaster));
LightLock_Init(&ndspMaster.lock);
ndspMaster.masterVol = 1.0f;
- ndspMaster.clippingMode = 1;
+ ndspMaster.outputMode = NDSP_OUTPUT_STEREO;
+ ndspMaster.clippingMode = NDSP_CLIP_SOFT;
ndspMaster.outputCount = 2;
ndspMaster.surround.depth = 0x7FFF;
ndspMaster.surround.rearRatio = 0x8000;