PS2SDK
PS2 Homebrew Libraries
|
#include <stdio.h>
#include <thbase.h>
#include <thsemap.h>
#include <loadcore.h>
#include <sysmem.h>
#include <intrman.h>
#include <libsd.h>
#include <sysclib.h>
#include <audsrv.h>
#include "audsrv_internal.h"
#include "common.h"
#include "rpc_server.h"
#include "spu.h"
#include "debug_printf.h"
Go to the source code of this file.
Data Structures | |
struct | adpcm_list_t |
Typedefs | |
typedef struct adpcm_list_t | adpcm_list_t |
Functions | |
static u32 sbuffer[16] | __attribute__ ((aligned(16))) |
static adpcm_list_t * | alloc_new_sample (void) |
static void | free_all_samples () |
int | free_sample (u32 id) |
static adpcm_list_t * | adpcm_loaded (int id) |
static void | audsrv_read_adpcm_header (adpcm_list_t *adpcm, const u32 *buffer) |
void * | audsrv_load_adpcm (u32 *buffer, int size, int id) |
int | audsrv_is_adpcm_playing (int ch, u32 id) |
static int | audsrv_adpcm_alloc_channel (void) |
int | audsrv_ch_play_adpcm (int ch, u32 id) |
int | audsrv_adpcm_init () |
int | audsrv_adpcm_set_volume (int ch, int voll, int volr) |
Variables | |
static adpcm_list_t * | adpcm_list_head = 0 |
static adpcm_list_t * | adpcm_list_tail = 0 |
audsrv adpcm module
Definition in file adpcm.c.
struct adpcm_list_t |
Data Fields | ||
---|---|---|
struct adpcm_list_t * | next | |
int | id | |
int | pitch | |
int | loop | |
int | channels | |
int | size | |
int | spu2_addr |
|
static |
Allocates memory for a new sample.
Definition at line 49 of file adpcm.c.
References CpuResumeIntr(), and CpuSuspendIntr().
Referenced by audsrv_load_adpcm().
|
static |
Frees up all memory taken by the linked list of samples
Definition at line 62 of file adpcm.c.
References CpuResumeIntr(), and CpuSuspendIntr().
Referenced by audsrv_adpcm_init().
int free_sample | ( | u32 | id | ) |
Remove an adpcm sample uploaded with audsrv_load_adpcm() from the list of loaded sounds
id | sample identifier, as specified in load() |
SPU memory is freed only when there are no sounds in the list that where loaded after the ones that have been freed
Definition at line 84 of file adpcm.c.
References AUDSRV_ERR_NOERROR, CpuResumeIntr(), and CpuSuspendIntr().
Referenced by rpc_command().
|
static |
Looks up the given identifier in list of loaded samples
id | sample identifier |
Definition at line 126 of file adpcm.c.
Referenced by audsrv_ch_play_adpcm(), and audsrv_load_adpcm().
|
static |
Extracts adpcm parameters from header
adpcm | node entry |
buffer | pointer to adpcm header |
Definition at line 147 of file adpcm.c.
Referenced by audsrv_load_adpcm().
void * audsrv_load_adpcm | ( | u32 * | buffer, |
int | size, | ||
int | id | ||
) |
Uploads a sample to SPU2 memory
buffer | pointer to adpcm sample header |
size | size of sample in bytes |
id | sample identifier (to be later used in play()) |
Definition at line 160 of file adpcm.c.
References adpcm_loaded(), alloc_new_sample(), and audsrv_read_adpcm_header().
int audsrv_ch_play_adpcm | ( | int | ch, |
u32 | id | ||
) |
Plays an adpcm sample already uploaded with audsrv_load_adpcm()
ch | channel identifier. Specifies one of the 24 voice channel to play the ADPCM channel on. If set to an invalid channel ID, an unoccupied channel will be selected. |
id | sample identifier, as specified in load() |
When ch is set to an invalid channel ID, the sample will be played in an unoccupied channel. If all 24 channels are used, then -AUDSRV_ERR_NO_MORE_CHANNELS is returned. When ch is set to a valid channel ID, -AUDSRV_ERR_NO_MORE_CHANNELS is returned if the channel is currently in use. Trying to play a sample which is unavailable will result in -AUDSRV_ERR_ARGS
Definition at line 277 of file adpcm.c.
References adpcm_loaded().
int audsrv_adpcm_init | ( | ) |
Initializes adpcm unit of audsrv
Definition at line 319 of file adpcm.c.
References AUDSRV_ERR_NOERROR, AUDSRV_INIT_ADPCM, call_rpc_1(), and free_all_samples().
Referenced by _start(), audsrv_quit(), and rpc_command().
int audsrv_adpcm_set_volume | ( | int | ch, |
int | voll, | ||
int | volr | ||
) |
Sets output volume for the specified voice channel.
ch | Voice channel ID |
voll | left volume in SPU2 units [0 .. 0x3fff] |
volr | right volume in SPU2 units [0 .. 0x3fff] |
Definition at line 347 of file adpcm.c.
References AUDSRV_ERR_NOERROR, and MAX_VOLUME.
|
static |
|
static |