ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
ps2snd.h File Reference
#include <tamtypes.h>
#include <libsd.h>
+ Include dependency graph for ps2snd.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define STREAM_STEREO   1
 
#define STREAM_END_CLOSE   0x0000
 
#define STREAM_END_REPEAT   0x1000
 
#define BINDID_PS2SND   0x80068000
 
#define PS2SND_Init   4
 
#define PS2SND_SetParam   5
 
#define PS2SND_GetParam   6
 
#define PS2SND_SetSwitch   7
 
#define PS2SND_GetSwitch   8
 
#define PS2SND_SetAddr   9
 
#define PS2SND_GetAddr   10
 
#define PS2SND_SetCoreAttr   11
 
#define PS2SND_GetCoreAttr   12
 
#define PS2SND_Note2Pitch   13
 
#define PS2SND_Pitch2Note   14
 
#define PS2SND_ProcBatch   15
 
#define PS2SND_ProcBatchEx   16
 
#define PS2SND_VoiceTrans   17
 
#define PS2SND_BlockTrans   18
 
#define PS2SND_VoiceTransStatus   19
 
#define PS2SND_BlockTransStatus   20
 
#define PS2SND_SetTransCallback   21
 
#define PS2SND_SetIRQCallback   22
 
#define PS2SND_SetEffectAttr   23
 
#define PS2SND_GetEffectAttr   24
 
#define PS2SND_ClearEffectWorkArea   25
 
#define PS2SND_SetTransIntrHandler   26
 
#define PS2SND_SetSpu2IntrHandler   27
 
#define PS2SND_StreamOpen   64
 
#define PS2SND_StreamClose   65
 
#define PS2SND_StreamPlay   66
 
#define PS2SND_StreamPause   67
 
#define PS2SND_StreamSetPosition   68
 
#define PS2SND_StreamGetPosition   69
 
#define PS2SND_StreamSetVolume   70
 
#define PS2SND_QueryMaxFreeMemSize   99 /* XXX: Hack until i can figure out how to do it right */
 

Functions

int sndLoadSample (void *buf, u32 spuaddr, int size)
 
u32 sndQueryMaxFreeMemSize (void)
 
int sndStreamOpen (char *file, u32 voices, u32 flags, u32 bufaddr, u32 bufsize)
 
int sndStreamClose (void)
 
int sndStreamPlay (void)
 
int sndStreamPause (void)
 
int sndStreamSetPosition (int block)
 
int sndStreamGetPosition (void)
 
int sndStreamSetVolume (int left, int right)
 

Detailed Description

PS2SND definitions.

Definition in file ps2snd.h.

Macro Definition Documentation

◆ BINDID_PS2SND

#define BINDID_PS2SND   0x80068000

Definition at line 26 of file ps2snd.h.

◆ PS2SND_BlockTrans

#define PS2SND_BlockTrans   18

Definition at line 42 of file ps2snd.h.

◆ PS2SND_BlockTransStatus

#define PS2SND_BlockTransStatus   20

Definition at line 44 of file ps2snd.h.

◆ PS2SND_ClearEffectWorkArea

#define PS2SND_ClearEffectWorkArea   25

Definition at line 49 of file ps2snd.h.

◆ PS2SND_GetAddr

#define PS2SND_GetAddr   10

Definition at line 34 of file ps2snd.h.

◆ PS2SND_GetCoreAttr

#define PS2SND_GetCoreAttr   12

Definition at line 36 of file ps2snd.h.

◆ PS2SND_GetEffectAttr

#define PS2SND_GetEffectAttr   24

Definition at line 48 of file ps2snd.h.

◆ PS2SND_GetParam

#define PS2SND_GetParam   6

Definition at line 30 of file ps2snd.h.

◆ PS2SND_GetSwitch

#define PS2SND_GetSwitch   8

Definition at line 32 of file ps2snd.h.

◆ PS2SND_Init

#define PS2SND_Init   4

Definition at line 28 of file ps2snd.h.

◆ PS2SND_Note2Pitch

#define PS2SND_Note2Pitch   13

Definition at line 37 of file ps2snd.h.

◆ PS2SND_Pitch2Note

#define PS2SND_Pitch2Note   14

Definition at line 38 of file ps2snd.h.

◆ PS2SND_ProcBatch

#define PS2SND_ProcBatch   15

Definition at line 39 of file ps2snd.h.

◆ PS2SND_ProcBatchEx

#define PS2SND_ProcBatchEx   16

Definition at line 40 of file ps2snd.h.

◆ PS2SND_QueryMaxFreeMemSize

#define PS2SND_QueryMaxFreeMemSize   99 /* XXX: Hack until i can figure out how to do it right */

Definition at line 62 of file ps2snd.h.

◆ PS2SND_SetAddr

#define PS2SND_SetAddr   9

Definition at line 33 of file ps2snd.h.

◆ PS2SND_SetCoreAttr

#define PS2SND_SetCoreAttr   11

Definition at line 35 of file ps2snd.h.

◆ PS2SND_SetEffectAttr

#define PS2SND_SetEffectAttr   23

Definition at line 47 of file ps2snd.h.

◆ PS2SND_SetIRQCallback

#define PS2SND_SetIRQCallback   22

Definition at line 46 of file ps2snd.h.

◆ PS2SND_SetParam

#define PS2SND_SetParam   5

Definition at line 29 of file ps2snd.h.

◆ PS2SND_SetSpu2IntrHandler

#define PS2SND_SetSpu2IntrHandler   27

Definition at line 51 of file ps2snd.h.

◆ PS2SND_SetSwitch

#define PS2SND_SetSwitch   7

Definition at line 31 of file ps2snd.h.

◆ PS2SND_SetTransCallback

#define PS2SND_SetTransCallback   21

Definition at line 45 of file ps2snd.h.

◆ PS2SND_SetTransIntrHandler

#define PS2SND_SetTransIntrHandler   26

Definition at line 50 of file ps2snd.h.

◆ PS2SND_StreamClose

#define PS2SND_StreamClose   65

Definition at line 54 of file ps2snd.h.

◆ PS2SND_StreamGetPosition

#define PS2SND_StreamGetPosition   69

Definition at line 58 of file ps2snd.h.

◆ PS2SND_StreamOpen

#define PS2SND_StreamOpen   64

Definition at line 53 of file ps2snd.h.

◆ PS2SND_StreamPause

#define PS2SND_StreamPause   67

Definition at line 56 of file ps2snd.h.

◆ PS2SND_StreamPlay

#define PS2SND_StreamPlay   66

Definition at line 55 of file ps2snd.h.

◆ PS2SND_StreamSetPosition

#define PS2SND_StreamSetPosition   68

Definition at line 57 of file ps2snd.h.

◆ PS2SND_StreamSetVolume

#define PS2SND_StreamSetVolume   70

Definition at line 59 of file ps2snd.h.

◆ PS2SND_VoiceTrans

#define PS2SND_VoiceTrans   17

Definition at line 41 of file ps2snd.h.

◆ PS2SND_VoiceTransStatus

#define PS2SND_VoiceTransStatus   19

Definition at line 43 of file ps2snd.h.

◆ STREAM_END_CLOSE

#define STREAM_END_CLOSE   0x0000

Definition at line 23 of file ps2snd.h.

◆ STREAM_END_REPEAT

#define STREAM_END_REPEAT   0x1000

Definition at line 24 of file ps2snd.h.

◆ STREAM_STEREO

#define STREAM_STEREO   1

Definition at line 22 of file ps2snd.h.

Function Documentation

◆ sndLoadSample()

int sndLoadSample ( void *  buf,
u32  spuaddr,
int  size 
)

Definition at line 276 of file ps2snd.c.

277 {
278  void *iopbuf;
279  int id, iopfree;
280  SifDmaTransfer_t sifdma;
281 
282  iopfree = sndQueryMaxFreeMemSize()/2;
283  if (size>iopfree)
284  {
285  return(-1);
286  }
287 
288  iopbuf = SifAllocIopHeap(size);
289  if (iopbuf==0)
290  return(-1);
291 
292  FlushCache(0);
293 
294  sifdma.src = buf;
295  sifdma.dest = iopbuf;
296  sifdma.size = size;
297  sifdma.attr = 0;
298 
299  id = SifSetDma(&sifdma, 1);
300  while(SifDmaStat(id) >= 0);;
301  FlushCache(0);
302 
303  sceSdVoiceTrans(0, SD_TRANS_WRITE, iopbuf, (void*)spuaddr, size);
304  sceSdVoiceTransStatus(0, 1);
305 
306  SifFreeIopHeap(iopbuf);
307 
308  return(size);
309 }
void * SifAllocIopHeap(int size)
int SifFreeIopHeap(void *addr)
u32 SifSetDma(SifDmaTransfer_t *sdd, s32 len)
void FlushCache(s32 operation)
s32 SifDmaStat(u32 id)
#define SD_TRANS_WRITE
Definition: libsd-common.h:47
u32 sndQueryMaxFreeMemSize(void)
Definition: ps2snd.c:208
int sceSdVoiceTrans(s16 channel, u16 mode, u8 *m_addr, u32 *s_addr, u32 size)
Definition: ps2snd.c:139
u32 sceSdVoiceTransStatus(s16 channel, s16 flag)
Definition: ps2snd.c:157
void * dest
Definition: sifdma.h:55
void * src
Definition: sifdma.h:54

References SifDmaTransfer_t::attr, SifDmaTransfer_t::dest, FlushCache(), sceSdVoiceTrans(), sceSdVoiceTransStatus(), SD_TRANS_WRITE, SifAllocIopHeap(), SifDmaStat(), SifFreeIopHeap(), SifSetDma(), SifDmaTransfer_t::size, sndQueryMaxFreeMemSize(), and SifDmaTransfer_t::src.

◆ sndQueryMaxFreeMemSize()

u32 sndQueryMaxFreeMemSize ( void  )

Definition at line 208 of file ps2snd.c.

209 {
210  u32 buf[1] ALIGNED(64);
212  return(buf[0]);
213 }
#define ALIGNED(x)
Definition: kernel.h:50
static SifRpcClientData_t sd_client
Definition: ps2snd.c:18
#define PS2SND_QueryMaxFreeMemSize
Definition: ps2snd.h:62
int SifCallRpc(SifRpcClientData_t *client, int rpc_number, int mode, void *send, int ssize, void *receive, int rsize, SifRpcEndFunc_t end_function, void *end_param)
#define NULL
Definition: tamtypes.h:91
unsigned int u32
Definition: tamtypes.h:30

References ALIGNED, NULL, PS2SND_QueryMaxFreeMemSize, sd_client, and SifCallRpc().

Referenced by sndLoadSample().

◆ sndStreamClose()

int sndStreamClose ( void  )

Definition at line 230 of file ps2snd.c.

231 {
232  s32 buf[1] ALIGNED(64);
233  SifCallRpc(&sd_client, PS2SND_StreamClose, 0, NULL, 0, buf, 4, NULL, NULL);
234  return(buf[0]);
235 }
#define PS2SND_StreamClose
Definition: ps2snd.h:54
signed int s32
Definition: tamtypes.h:58

References ALIGNED, NULL, PS2SND_StreamClose, sd_client, and SifCallRpc().

◆ sndStreamGetPosition()

int sndStreamGetPosition ( void  )

Definition at line 269 of file ps2snd.c.

270 {
271  s32 buf[1] ALIGNED(64);
273  return(buf[0]);
274 }
#define PS2SND_StreamGetPosition
Definition: ps2snd.h:58

References ALIGNED, NULL, PS2SND_StreamGetPosition, sd_client, and SifCallRpc().

◆ sndStreamOpen()

int sndStreamOpen ( char *  file,
u32  voices,
u32  flags,
u32  bufaddr,
u32  bufsize 
)

Definition at line 215 of file ps2snd.c.

216 {
217  u32 buf[32] ALIGNED(64);
218  buf[0] = voices;
219  buf[1] = flags;
220  buf[2] = bufaddr;
221  buf[3] = bufsize;
222  strncpy((char*)&buf[4], file, 27*4);
223  buf[31] = 0;
224 
225  SifCallRpc(&sd_client, PS2SND_StreamOpen, 0, buf, 128, buf, 4, NULL, NULL);
226  return(((s32 *)buf)[0]);
227 }
#define PS2SND_StreamOpen
Definition: ps2snd.h:53

References ALIGNED, NULL, PS2SND_StreamOpen, sd_client, and SifCallRpc().

Referenced by main().

◆ sndStreamPause()

int sndStreamPause ( void  )

Definition at line 245 of file ps2snd.c.

246 {
247  s32 buf[1] ALIGNED(64);
248  SifCallRpc(&sd_client, PS2SND_StreamPause, 0, NULL, 0, buf, 4, NULL, NULL);
249  return(buf[0]);
250 }
#define PS2SND_StreamPause
Definition: ps2snd.h:56

References ALIGNED, NULL, PS2SND_StreamPause, sd_client, and SifCallRpc().

◆ sndStreamPlay()

int sndStreamPlay ( void  )

Definition at line 237 of file ps2snd.c.

238 {
239  s32 buf[1] ALIGNED(64);
240  SifCallRpc(&sd_client, PS2SND_StreamPlay, 0, NULL, 0, buf, 4, NULL, NULL);
241  return(buf[0]);
242 }
#define PS2SND_StreamPlay
Definition: ps2snd.h:55

References ALIGNED, NULL, PS2SND_StreamPlay, sd_client, and SifCallRpc().

Referenced by main().

◆ sndStreamSetPosition()

int sndStreamSetPosition ( int  block)

Definition at line 252 of file ps2snd.c.

253 {
254  s32 buf[1] ALIGNED(64);
255  buf[0] = block;
256  SifCallRpc(&sd_client, PS2SND_StreamSetPosition, 0, buf, 4, buf, 4, NULL, NULL);
257  return(buf[0]);
258 }
#define PS2SND_StreamSetPosition
Definition: ps2snd.h:57

References ALIGNED, NULL, PS2SND_StreamSetPosition, sd_client, and SifCallRpc().

◆ sndStreamSetVolume()

int sndStreamSetVolume ( int  left,
int  right 
)

Definition at line 260 of file ps2snd.c.

261 {
262  s32 buf[2] ALIGNED(64);
263  buf[0] = left;
264  buf[1] = right;
265  SifCallRpc(&sd_client, PS2SND_StreamSetVolume, 0, buf, 8, buf, 4, NULL, NULL);
266  return(buf[0]);
267 }
#define PS2SND_StreamSetVolume
Definition: ps2snd.h:59

References ALIGNED, NULL, PS2SND_StreamSetVolume, sd_client, and SifCallRpc().