Japanese
PROGRAMMER'S GUIDEPCM/ADPCM playback library
BackForward
PCM/ADPCM playback library

3.Playback procedure


(1) Playback procedure
Figure 3.1 shows the steps to play using the stream system.

Figure 3.1 Playback procedure during stream playback

(2) Program example
The following is an example program that uses the stream system to play AIFF or APCM format files.

	#define RING_BUF_SIZE (2048L*10)
	#define PCM_ADDR ((void*)0x25a20000)
	#define PCM_SIZE (4096L*2)

	/* work */
	PcmWork pcm_work;

	/* ring buffer */
	Uint32 ring_buf[RING_BUF_SIZE / sizeof(Uint32)];
	StmHn stm;
	PcmHn pcm;

	/* Initialize sound */
	SND_Init(・・);

	/* Initialization */
	PCM_Init();

	/* ADPCM usage declaration (required when using ADPCM) */
	PCM_DeclareUseAdpcm();

	/* Interrupt handling settings */
Set the V blank IN interrupt using INT_???.
Call PCM_VblIn(); within the V blank IN interrupt.

	/* File initialization */
	GFS_Init(・・);
	STM_Init(・・);
	STM_OpenGrp();
	STM_SetExecGrp(・・);
	/* Open stream */
	stm = STM_OpenFid(・・);

	/* Generate handle */
	PCM_PARA_WORK(&para) = &pcm_work;
	PCM_PARA_RING_ADDR(&para) = ring_buf;
	PCM_PARA_RING_SIZE(&para) = RING_BUF_SIZE;
	PCM_PARA_PCM_ADDR(&para) = PCM_ADDR;
	PCM_PARA_PCM_SIZE(&para) = PCM_SIZE;
	pcm = PCM_CreateStmHandle(&para, stm);

	/* Start playing */
	PCM_Start(pcm);
	while(TRUE) {
                /* Run the server */
                STM_ExecServer();

		/* Playback task processing */
		PCM_Task(pcm);

		/* End judgment */
		if (PCM_GetPlayStatus(pcm) == PCM_STAT_PLAY_END) break;
	}
	/* Abandoning handle */
	PCM_DestroyStmHandle(pcm);

	/* Close stream */
	STM_Close(stm);

    /* End processing */
       PCM_Finish();


BackForward
PROGRAMMER'S GUIDEPCM/ADPCM playback library
Copyright SEGA ENTERPRISES, LTD., 1997