ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
playadpcm.c File Reference
#include <stdio.h>
#include <string.h>
#include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <tamtypes.h>
#include <audsrv.h>
+ Include dependency graph for playadpcm.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file playadpcm.c.

23 {
24  /* Uncomment to hear two samples played simultaenously
25  int i;
26  */
27  int ret;
28  FILE* adpcm;
29  audsrv_adpcm_t sample;
30  int size;
31  u8* buffer;
32 
33  SifInitRpc(0);
34 
35  printf("sample: kicking IRXs\n");
36  ret = SifLoadModule("rom0:LIBSD", 0, NULL);
37  printf("libsd loadmodule %d\n", ret);
38 
39  printf("sample: loading audsrv\n");
40  ret = SifLoadModule("host:audsrv.irx", 0, NULL);
41  printf("audsrv loadmodule %d\n", ret);
42 
43  ret = audsrv_init();
44  if (ret != 0)
45  {
46  printf("sample: failed to initialize audsrv\n");
47  printf("audsrv returned error string: %s\n", audsrv_get_error_string());
48  return 1;
49  }
50 
51  adpcm = fopen("host:evillaugh.adp", "rb");
52 
53  if (adpcm == NULL)
54  {
55  printf("failed to open adpcm file\n");
56  audsrv_quit();
57  return 1;
58  }
59 
60  fseek(adpcm, 0, SEEK_END);
61  size = ftell(adpcm);
62  fseek(adpcm, 0, SEEK_SET);
63 
64  buffer = malloc(size);
65 
66  fread(buffer, 1, size, adpcm);
67  fclose(adpcm);
68 
69  printf("playing sample..\n");
70 
74  audsrv_load_adpcm(&sample, buffer, size);
75  audsrv_ch_play_adpcm(0, &sample);
76 
77  /* Uncomment to hear two samples played simultaenously
78  for (i=0; i<100; i++)
79  {
80  nopdelay();
81  }
82 
83  audsrv_adpcm_set_volume(1, MAX_VOLUME);
84  audsrv_ch_play_adpcm(1, &sample);
85  */
86 
87  printf("sample played..\n");
88 
89  free(buffer);
90 
91  while (1);
92  return 0;
93 }
const char * audsrv_get_error_string()
Definition: audsrv_rpc.c:438
int audsrv_init()
Definition: audsrv_rpc.c:296
int audsrv_adpcm_init()
Definition: audsrv_rpc.c:362
int audsrv_adpcm_set_volume(int ch, int vol)
Definition: audsrv_rpc.c:367
int audsrv_ch_play_adpcm(int ch, audsrv_adpcm_t *adpcm)
Definition: audsrv_rpc.c:432
#define MAX_VOLUME
Definition: audsrv.h:25
int audsrv_load_adpcm(audsrv_adpcm_t *adpcm, void *buffer, int size)
Definition: audsrv_rpc.c:381
int audsrv_set_volume(int volume)
Definition: audsrv_rpc.c:157
int audsrv_quit()
Definition: audsrv_rpc.c:117
int SifLoadModule(const char *path, int arg_len, const char *args)
u8 buffer[128]
Definition: rpc_client.c:19
void SifInitRpc(int mode)
#define NULL
Definition: tamtypes.h:91
unsigned char u8
Definition: tamtypes.h:23

References audsrv_adpcm_init(), audsrv_adpcm_set_volume(), audsrv_ch_play_adpcm(), audsrv_get_error_string(), audsrv_init(), audsrv_load_adpcm(), audsrv_quit(), audsrv_set_volume(), buffer, MAX_VOLUME, NULL, SifInitRpc(), and SifLoadModule().