Example #1
0
int main(void)
{
	int ret;
	/* Load LibSD (freesd will work too one day, I promise ;) */
	ret = SifLoadModule("host:LIBSD.IRX", 0, NULL);
	if (ret<0)
	{
		printf("XXXXX failed to load host:LIBSD.IRX (%d)\n", ret);
		SleepThread();
	}

	/* Load ps2snd */
	ret = SifLoadModule("host:ps2snd.irx", 0, NULL);
	if (ret<0)
	{
		printf("XXXXX failed to load host:ps2snd.irx (%d)\n", ret);
		SleepThread();
	}

	/* Start LibSD */
	if (sceSdInit(0)<0)
	{
		printf("Failed to start LibSD\n");
		SleepThread();
	}

	/* Setup master volumes for both cores */
	sceSdSetParam(0 | SD_PARAM_MVOLL, 0x3fff);
	sceSdSetParam(0 | SD_PARAM_MVOLR, 0x3fff);
	sceSdSetParam(1 | SD_PARAM_MVOLL, 0x3fff);
	sceSdSetParam(1 | SD_PARAM_MVOLR, 0x3fff);

	/*
		Open a stream, using voices 0:22 and 0:23
		It's stereo and it should be closed when the end is hit.
		The SPU buffers are at 0x6000 in spu2 ram.
		The chunksize is 1024 blocks (16kbyte)
	*/
	if (sndStreamOpen("host:stream.adpcm", SD_VOICE(0,22) | (SD_VOICE(0,23)<<16), STREAM_STEREO | STREAM_END_CLOSE, 0x6000, 1024)<0)
	{
		printf("Failed to open stream\n");
		SleepThread();
	}


	sndStreamPlay();

	SleepThread();

	return(0);
}
Example #2
0
void *rpc_server(u32 func, void *data, u32 size)
{
	u32 *ru = rpc_buffer[1];
	s32  *rs = rpc_buffer[1];
	
	switch(func)
	{
	case PS2SND_Init:             *rs = sceSdInit       (DS[0]); break;
	case PS2SND_SetParam:               sceSdSetParam   (DU[0], DU[1]); break;
	case PS2SND_GetParam:         *ru = sceSdGetParam   (DU[0]); break;
	case PS2SND_SetSwitch:              sceSdSetSwitch  (DU[0], DU[1]); break;
	case PS2SND_GetSwitch:        *ru = sceSdGetSwitch  (DU[0]); break;
	case PS2SND_SetAddr:                sceSdSetAddr    (DU[0], DU[1]); break;
	case PS2SND_GetAddr:          *ru = sceSdGetAddr    (DU[0]); break;
	case PS2SND_SetCoreAttr:            sceSdSetCoreAttr(DU[0], DU[1]); break;
	case PS2SND_GetCoreAttr:      *ru = sceSdGetCoreAttr(DU[0]); break;
	case PS2SND_Note2Pitch:       *ru = sceSdNote2Pitch (DU[0], DU[1], DU[2], DS[3]); break;
	case PS2SND_Pitch2Note:       *ru = sceSdPitch2Note (DU[0], DU[1], DU[2]); break;
	case PS2SND_ProcBatch:        *rs = sceSdProcBatch  ((SdBatch *)&DU[1], &ru[1], DU[0]); break;
	case PS2SND_ProcBatchEx:      *rs = sceSdProcBatchEx((SdBatch *)&DU[2], &ru[1], DU[0], DU[1]); break;
	case PS2SND_VoiceTrans:       *rs = sceSdVoiceTrans(DS[0], DU[1], (u8 *)DU[2], (u8 *)DU[3], DU[4]); break;
	case PS2SND_BlockTrans:       *rs = sceSdBlockTrans(DS[0], DU[1], (u8 *)DU[2], DU[3], DU[4]); break;
	case PS2SND_VoiceTransStatus: *ru = sceSdVoiceTransStatus (DS[0], DS[1]); break;
	case PS2SND_BlockTransStatus: *ru = sceSdBlockTransStatus (DS[0], DS[1]); break;
//	case PS2SND_SetTransCallback: void* sceSdSetTransCallback (u16 channel, void SD_TRANS_CBProc(void *) );
//	case PS2SND_SetIRQCallback:   void* sceSdSetIRQCallback ( void SD_IRQ_CBProc(void *) );
	case PS2SND_SetEffectAttr:    *rs = sceSdSetEffectAttr (DU[0], (SdEffectAttr *)&DU[1]); break;
	case PS2SND_GetEffectAttr:          sceSdGetEffectAttr (DU[0], (SdEffectAttr *)rpc_buffer[1]); break;
	case PS2SND_ClearEffectWorkArea: *rs = sceSdClearEffectWorkArea (DS[0], DS[1], DS[2]); break;
//	case PS2SND_SetTransIntrHandler: SdIntrHandler sceSdSetTransIntrHandler(int channel, SdIntrHandler func, void *arg);
//	case PS2SND_SetSpu2IntrHandler:  SdIntrHandler sceSdSetSpu2IntrHandler(SdIntrHandler func, void *arg);

	case PS2SND_StreamOpen:  *rs = sndStreamOpen((char*)&DS[4], DU[0], DU[1], DU[2], DU[3]); break;
	case PS2SND_StreamClose: *rs = sndStreamClose(); break;
	case PS2SND_StreamPlay:  *rs = sndStreamPlay(); break;
	case PS2SND_StreamPause: *rs = sndStreamPause(); break;
	case PS2SND_StreamSetPosition: *rs = sndStreamSetPosition(DS[0]); break;
	case PS2SND_StreamGetPosition: *rs = sndStreamGetPosition(); break;
	case PS2SND_StreamSetVolume:   *rs = sndStreamSetVolume(DS[0], DS[1]); break;

	case PS2SND_QueryMaxFreeMemSize: *ru = QueryMaxFreeMemSize(); break;
	default:
		dprintf(OUT_WARNING, "Unknown function id '%u'\n", (unsigned int)func);
		return(NULL);
	}

	return(rpc_buffer[1]);
}