ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
stream.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2005, James Lee (jbit<at>jbit<dot>net)
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
11 #include <kernel.h>
12 #include <loadfile.h>
13 #include <stdio.h>
14 #include <ps2snd.h>
15 
16 int main(void)
17 {
18  int ret;
19  /* Load LibSD (freesd will work too one day, I promise ;) */
20  ret = SifLoadModule("host:LIBSD.IRX", 0, NULL);
21  if (ret<0)
22  {
23  printf("XXXXX failed to load host:LIBSD.IRX (%d)\n", ret);
24  SleepThread();
25  }
26 
27  /* Load ps2snd */
28  ret = SifLoadModule("host:ps2snd.irx", 0, NULL);
29  if (ret<0)
30  {
31  printf("XXXXX failed to load host:ps2snd.irx (%d)\n", ret);
32  SleepThread();
33  }
34 
35  /* Start LibSD */
36  if (sceSdInit(0)<0)
37  {
38  printf("Failed to start LibSD\n");
39  SleepThread();
40  }
41 
42  /* Setup master volumes for both cores */
43  sceSdSetParam(0 | SD_PARAM_MVOLL, 0x3fff);
44  sceSdSetParam(0 | SD_PARAM_MVOLR, 0x3fff);
45  sceSdSetParam(1 | SD_PARAM_MVOLL, 0x3fff);
46  sceSdSetParam(1 | SD_PARAM_MVOLR, 0x3fff);
47 
48  /*
49  Open a stream, using voices 0:22 and 0:23
50  It's stereo and it should be closed when the end is hit.
51  The SPU buffers are at 0x6000 in spu2 ram.
52  The chunksize is 1024 blocks (16kbyte)
53  */
54  if (sndStreamOpen("host:stream.adpcm", SD_VOICE(0,22) | (SD_VOICE(0,23)<<16), STREAM_STEREO | STREAM_END_CLOSE, 0x6000, 1024)<0)
55  {
56  printf("Failed to open stream\n");
57  SleepThread();
58  }
59 
60 
61  sndStreamPlay();
62 
63  SleepThread();
64 
65  return(0);
66 }
67 
int SifLoadModule(const char *path, int arg_len, const char *args)
s32 SleepThread(void)
#define SD_PARAM_MVOLL
Definition: libsd-common.h:35
#define SD_VOICE(_core, _v)
Definition: libsd-common.h:11
#define SD_PARAM_MVOLR
Definition: libsd-common.h:36
void sceSdSetParam(u16 entry, u16 value)
Definition: ps2snd.c:50
int sndStreamOpen(char *file, u32 voices, u32 flags, u32 bufaddr, u32 bufsize)
Definition: ps2snd.c:215
int sndStreamPlay(void)
Definition: ps2snd.c:237
int sceSdInit(int flag)
Definition: ps2snd.c:21
#define STREAM_END_CLOSE
Definition: ps2snd.h:23
#define STREAM_STEREO
Definition: ps2snd.h:22
int main(void)
Definition: stream.c:16
#define NULL
Definition: tamtypes.h:91