More posts
I'm not sure why the Stream library is working in Yabause and not working on real hardware or in SSF.
Clearly some of the commands are "getting through"
Still not getting any sound, by the way, but understanding the stream system would be first.
/e: It has something to do with the CD-ROM XA keys. So commenting out the one line with 0x04 ant at least the Stream works in SSF.
The documentation does say CD-ROM XA needs the CD to be formatted as Mode 2 Form 2... how would I format like that, or is it even relevant?
#ifndef __AUDIO_H__
#define __AUDIO_H__
#define RING_BUF_SIZE (2048L*10)
#define PCM_ADDR ((void*)0x25a20000)
#define PCM_SIZE (4096L*2)
#define SMP_1TASK_SAMPLE (1024)
#define SMP_TR_MODE_CD (PCM_TRMODE_SCU)
#define SMP_LOAD_NUM (10)
#define SND_RAM (94371840)
#define LW_RAM (2097152)
//Functions go here
void adpcm_load(void);
#endif
//audio.c
//this file is compiled separately
#include <jo/jo.h>
#include "audio.h"
//goals:
//Apparently, this file is CD-ROM XA.
void adpcm_load(void){
/* Work */
PcmWork pcm_work;
PcmCreatePara para;
/* Ring Buffer */
Uint32 ring_buf[RING_BUF_SIZE / sizeof(Uint32)];
// Handles
StmHn stm;
PcmHn pcm;
StmGrpHn stmfpcm;
StmKey key;
PcmInfo info;
Sint8* name = "SHELL.ADP";
Sint32 fid = GFS_NameToId(name);
//Data of read in process
Sint32 rdsize;
/* Set Interrupt Process */
// Use
// INT_???
// and set V-Blank IN interrupt.
// Call
// PCM_VblIn();
// within V-Blank IN interrupt.
/* File initialization */
stmfpcm = STM_OpenGrp();
STM_SetExecGrp(stmfpcm);
STM_KEY_FN(&key) = STM_KEY_CN(&key) = STM_KEY_SMMSK(&key) =
STM_KEY_SMVAL(&key) = STM_KEY_CIMSK(&key) = STM_KEY_CIVAL(&key) =
STM_KEY_NONE;
//FOR CDROM XA
STM_KEY_SMMSK(&key) = STM_KEY_SMVAL(&key) = 0x04;/* Audio Sector */
STM_KEY_CN(&key) = 0; /* channel No. */
/* Open Stream */
stm = STM_OpenFid(stmfpcm, fid, &key, STM_LOOP_NOREAD);
/* Create Handle */
PCM_PARA_WORK(¶) = &pcm_work;
PCM_PARA_RING_ADDR(¶) = ring_buf;
PCM_PARA_RING_SIZE(¶) = RING_BUF_SIZE;
PCM_PARA_PCM_ADDR(¶) = PCM_ADDR;
PCM_PARA_PCM_SIZE(¶) = PCM_SIZE;
pcm = PCM_CreateStmHandle(¶, stm);
//SET PCM INFO FOR ADPCM
PCM_INFO_FILE_TYPE(&info) = PCM_FILE_TYPE_NO_HEADER;
PCM_INFO_DATA_TYPE(&info) = PCM_DATA_TYPE_ADPCM_SCT;
PCM_SetVolume(pcm, 7);
PCM_SetInfo(pcm, &info);
PCM_SetLoadNum(pcm, SMP_LOAD_NUM);
PCM_SetTrModeCd(pcm, SMP_TR_MODE_CD);
PCM_Set1TaskSample(pcm, SMP_1TASK_SAMPLE);
PCM_ChangePcmPara(pcm);
/* Start Playback */
PCM_Start(pcm);
while(TRUE) {
STM_ExecServer();
rdsize = STM_GetNumCdbuf(stm);
jo_printf(0, 0, "(%i)", rdsize);
/* Playback task processing */
PCM_Task(pcm);
/* End condition */
if (PCM_GetPlayStatus(pcm) == PCM_STAT_PLAY_END) break;
if(jo_is_pad1_key_pressed(JO_KEY_A)){
break;
}
}
/* Destroy Handle */
PCM_DestroyStmHandle(pcm);
/* Close stream */
STM_Close(stm);
/* End Processing */
PCM_Finish();
}
/e: You can add these, it doesn't seem to care. I might get somewhere in a few years.
info.sampling_rate = 18900;
info.sampling_bit = 16;
info.channel = 1;
info.sample_file = 1;
More /e:
Frankly I don't even know where the data from the stream is going.
STM_SetTrBuf(stm, ring_buf, 2048, RING_BUF_SIZE);
doesn't seem to change anything.
Also, thank you again for clarifying that encoder is for XA audio. It IS headerless...