/*
* Monaural on-memory PCM stream sample
*/
/* Base parameters */
#define BASE_VOL (0x7F)
#define BASE_PAN (0x40)
#define BASE_FX_CH (0x00)
#define BASE_FX_LEV (0x00)
#define BASE_DRCT_LEV (0x7F)
#define BASE_FILTER_LEV (SDD_PSTM_PORT_SLOT_FILTER_THROUGH)
#define BASE_FILER_Q (0x00)
/* Playback waveform size */
#define WAVE_SZ (0x10000)
/* Size to transfer to ring buffer */
#define TRANSFER_SZ (0x1000)
/* Loop or not */
#define LOOP_FLG (true)
SDPSTM pstm_handle;
SDMEMBLK memblk;
Void *src_wave; /* Source waveform value must be divisible by transfer_sz */
src_wave = syMalloc( WAVE_SZ); /* Address of wavefore for actual playback */
sdMemBlkCreate( &memblk);
sdMemBlkSetPrm( memblk, src_wave, WAVE_SZ, SDD_MEMBLK_NO_FUNC, NULL);
/* Get PCM stream port access permission, using PCM stream ring buffer index 0 */
sdPstmOpen( &pstm_handle, 1, 0);
/* Set base parameters */
sdPstmSetBasePrm( pstm_handle, SDD_PSTM_PORT_SLOT_ALL,
BASE_VOL, BASE_PAN, BASE_FX_CH, BASE_FX_LEV,
BASE_DRCT_LEV, BASE_FILTER_LEV, BASE_FILTER_Q);
/* Set source memory block for on-memory playback */
sdPstmOnMemSetWaveData( pstm_handle, 0, memblk);
/* On-memory playback */
sdPstmOnMemPlay( pstm_handle, SDE_PCM_TYPE_16BIT_LINEAR,
44100, TRANSFER_SZ, LOOP_FLG);
/* Game processing */
main_loop();
/* Stop playback */
sdPstmStop( pstm_handle);
/* Termination processing */
sdMemBlkDestroy( memblk);
sdPstmClose( pstm_handle);
syMalloc( src_wave);