20int sceSdInit(
int flag)
22 s32 buf[1] ALIGNED(64);
28 if (SifBindRpc(&sd_client, BINDID_PS2SND, 0) < 0)
30 printf(
"%s: Failed to bind to rpc '0x%08x'\n", __FUNCTION__, BINDID_PS2SND);
34 if (sd_client.server != NULL)
43 SifCallRpc(&sd_client, PS2SND_Init, 0, buf, 4, buf, 4, NULL, NULL);
48void sceSdSetParam(u16 entry, u16 value)
50 u32 buf[2] ALIGNED(64);
53 SifCallRpc(&sd_client, PS2SND_SetParam, 0, buf, 8, NULL, 0, NULL, NULL);
56u16 sceSdGetParam(u16 entry)
58 u32 buf[1] ALIGNED(64);
60 SifCallRpc(&sd_client, PS2SND_GetParam, 0, buf, 4, buf, 4, NULL, NULL);
64void sceSdSetSwitch(u16 entry, u32 value)
66 u32 buf[2] ALIGNED(64);
69 SifCallRpc(&sd_client, PS2SND_SetSwitch, 0, buf, 8, NULL, 0, NULL, NULL);
72u32 sceSdGetSwitch(u16 entry)
74 u32 buf[1] ALIGNED(64);
76 SifCallRpc(&sd_client, PS2SND_GetSwitch, 0, buf, 4, buf, 4, NULL, NULL);
80void sceSdSetAddr(u16 entry, u32 value)
82 u32 buf[2] ALIGNED(64);
85 SifCallRpc(&sd_client, PS2SND_SetAddr, 0, buf, 8, NULL, 0, NULL, NULL);
88u32 sceSdGetAddr(u16 entry)
90 u32 buf[1] ALIGNED(64);
92 SifCallRpc(&sd_client, PS2SND_GetAddr, 0, buf, 4, buf, 4, NULL, NULL);
96void sceSdSetCoreAttr(u16 entry, u16 value)
98 u32 buf[2] ALIGNED(64);
101 SifCallRpc(&sd_client, PS2SND_SetCoreAttr, 0, buf, 8, NULL, 0, NULL, NULL);
104u16 sceSdGetCoreAttr(u16 entry)
106 u32 buf[1] ALIGNED(64);
108 SifCallRpc(&sd_client, PS2SND_GetCoreAttr, 0, buf, 4, buf, 4, NULL, NULL);
112u16 sceSdNote2Pitch(u16 center_note, u16 center_fine, u16 note, s16 fine)
123u16 sceSdPitch2Note(u16 center_note, u16 center_fine, u16 pitch)
133int sceSdProcBatch(
sceSdBatch* batch, u32 returns[], u32 num)
143int sceSdProcBatchEx(
sceSdBatch* batch, u32 returns[], u32 num, u32 voice)
155int sceSdVoiceTrans(s16 channel, u16 mode, u8 *m_addr, u32 *s_addr, u32 size)
157 u32 buf[5] ALIGNED(64);
158 ((s32 *)buf)[0] = channel;
160 buf[2] = (u32)m_addr;
161 buf[3] = (u32)s_addr;
164 SifCallRpc(&sd_client, PS2SND_VoiceTrans, 0, buf, 20, buf, 4, NULL, NULL);
165 return(((s32 *)buf)[0]);
168int sceSdBlockTrans(s16 channel, u16 mode, u8 *m_addr, u32 size, ...)
178u32 sceSdVoiceTransStatus (s16 channel, s16 flag)
180 s32 buf[2] ALIGNED(64);
184 SifCallRpc(&sd_client, PS2SND_VoiceTransStatus, 0, buf, 8, buf, 4, NULL, NULL);
185 return(((u32 *)buf)[0]);
188u32 sceSdBlockTransStatus (s16 channel, s16 flag)
190 s32 buf[2] ALIGNED(64);
194 SifCallRpc(&sd_client, PS2SND_BlockTransStatus, 0, buf, 8, buf, 4, NULL, NULL);
195 return(((u32 *)buf)[0]);
206 SifCallRpc(&sd_client, PS2SND_SetEffectAttr, 0, buf, 4+
sizeof(
sceSdEffectAttr), buf, 4, NULL, NULL);
214 SifCallRpc(&sd_client, PS2SND_GetEffectAttr, 0, buf, 4, buf,
sizeof(
sceSdEffectAttr), NULL, NULL);
218int sceSdClearEffectWorkArea (
int core,
int channel,
int effect_mode)
220 s32 buf[3] ALIGNED(64);
223 buf[2] = effect_mode;
224 SifCallRpc(&sd_client, PS2SND_ClearEffectWorkArea, 0, buf, 12, buf, 4, NULL, NULL);
229u32 sndQueryMaxFreeMemSize(
void)
231 u32 buf[1] ALIGNED(64);
232 SifCallRpc(&sd_client, PS2SND_QueryMaxFreeMemSize, 0, NULL, 0, buf, 4, NULL, NULL);
236int sndStreamOpen(
char *file, u32 voices, u32 flags, u32 bufaddr, u32 bufsize)
238 u32 buf[32] ALIGNED(64);
243 strncpy((
char*)&buf[4], file, 27*4);
246 SifCallRpc(&sd_client, PS2SND_StreamOpen, 0, buf, 128, buf, 4, NULL, NULL);
247 return(((s32 *)buf)[0]);
251int sndStreamClose(
void)
253 s32 buf[1] ALIGNED(64);
254 SifCallRpc(&sd_client, PS2SND_StreamClose, 0, NULL, 0, buf, 4, NULL, NULL);
258int sndStreamPlay(
void)
260 s32 buf[1] ALIGNED(64);
261 SifCallRpc(&sd_client, PS2SND_StreamPlay, 0, NULL, 0, buf, 4, NULL, NULL);
266int sndStreamPause(
void)
268 s32 buf[1] ALIGNED(64);
269 SifCallRpc(&sd_client, PS2SND_StreamPause, 0, NULL, 0, buf, 4, NULL, NULL);
273int sndStreamSetPosition(
int block)
275 s32 buf[1] ALIGNED(64);
277 SifCallRpc(&sd_client, PS2SND_StreamSetPosition, 0, buf, 4, buf, 4, NULL, NULL);
281int sndStreamSetVolume(
int left,
int right)
283 s32 buf[2] ALIGNED(64);
286 SifCallRpc(&sd_client, PS2SND_StreamSetVolume, 0, buf, 8, buf, 4, NULL, NULL);
290int sndStreamGetPosition(
void)
292 s32 buf[1] ALIGNED(64);
293 SifCallRpc(&sd_client, PS2SND_StreamGetPosition, 0, NULL, 0, buf, 4, NULL, NULL);
297int sndLoadSample(
void *buf, u32 spuaddr,
int size)
303 iopfree = sndQueryMaxFreeMemSize()/2;
309 iopbuf = SifAllocIopHeap(size);
316 sifdma.dest = iopbuf;
320 id = SifSetDma(&sifdma, 1);
321 while(SifDmaStat(
id) >= 0);;
324 sceSdVoiceTrans(0, SD_TRANS_WRITE, iopbuf, (
void*)spuaddr, size);
325 sceSdVoiceTransStatus(0, 1);
327 SifFreeIopHeap(iopbuf);