HomeForumsWhat's newResources 
 
 
request : working sbl pcm player function
vbt - Oct 13, 2006
   vbt Oct 13, 2006 
if somebody can help, I'd like a simple and working sample to play a waveform file or buffer

   vbt Nov 7, 2006 
Request cancelled, I did it myself

   RockinB Nov 12, 2006 

  vbt said:
Request cancelled, I did it myself


Due to the limitations of SGL PCM playback and because the SBL sound playback functions can be used together with SGL, the pcm player demo you mentioned is very interesting.

I'm thinking about MOD players and custom ADPCM (MP3, OGG, what ever) decoders. A MOD player is something we'd need as urgent as an SDL port. Now that you managed to output sound with an emu on Saturn, the same approach can be used for a MOD player. Can you release the source code of the SBL pcm player demo?

   vbt Nov 18, 2006 

  RockinB said:
Due to the limitations of SGL PCM playback and because the SBL sound playback functions can be used together with SGL, the pcm player demo you mentioned is very interesting.


I'm thinking about MOD players and custom ADPCM (MP3, OGG, what ever) decoders. A MOD player is something we'd need as urgent as an SDL port. Now that you managed to output sound with an emu on Saturn, the same approach can be used for a MOD player. Can you release the source code of the SBL pcm player demo?



In fact the sound of the sms is converted to wave so I didn't develop my own function to play sound and the function used to read wave in SBL is pcm_AudioMix. I haven't developed a sound player sample but I can give what I did for sound playing from memory :


Code:
  
#include "sega_pcm.h" #include "sega_snd.h" ... #define RING_BUF_SIZE (2048L*10) #define PCM_ADDR ((void*)0x25a20000) #define PCM_SIZE (4096L*2) Sint8 *g_movie_buf = (Sint8 *)0x25a20000; PcmHn pcm; int delta; int frame; ... void UsrVblankIn( void ) { PCM_MeVblIn(); } static void sndInit(void) { SndIniDt snd_init; char sound_map[]={0xFF,0xFF}; #ifndef ACTION_REPLAY GFS_Load(GFS_NameToId(SDDRV_NAME),0,(void *) SDDRV_ADDR,SDDRV_SIZE); SND_INI_PRG_ADR(snd_init) = (Uint16 *)SDDRV_ADDR; SND_INI_PRG_SZ(snd_init) = (Uint16) SDDRV_SIZE; #else SND_INI_PRG_ADR(snd_init) = (Uint16 *)snddrv; SND_INI_PRG_SZ(snd_init) = (Uint16) sizeof(snddrv); #endif SND_INI_ARA_ADR(snd_init) = (Uint16 *)sound_map; SND_INI_ARA_SZ(snd_init) = (Uint16)sizeof(sound_map); SND_Init(&snd_init); SND_ChgMap(0); } static PcmHn createHandle(PcmCreatePara *para) { PcmHn pcm; pcm = PCM_CreateMemHandle(para); if (pcm == NULL) { return NULL; } PCM_NotifyWriteSize(pcm, 7680*2); return pcm; } void main() { delta=0; frame=0; sndInit(); PCM_MeInit(); PcmCreatePara para; PcmInfo info; PcmStatus *st; static PcmWork g_movie_work; PCM_PARA_WORK(&para) = (struct PcmWork *)&g_movie_work; PCM_PARA_RING_ADDR(&para) = (Sint8 *)g_movie_buf; PCM_PARA_RING_SIZE(&para) = RING_BUF_SIZE; PCM_PARA_PCM_ADDR(&para) = PCM_ADDR; PCM_PARA_PCM_SIZE(&para) = PCM_SIZE; st = &g_movie_work.status; memset((Sint8 *)g_movie_buf,0,7680L*4); st->need_ci = PCM_ON; PCM_INFO_FILE_TYPE(&info) = PCM_FILE_TYPE_NO_HEADER; PCM_INFO_DATA_TYPE(&info)=PCM_DATA_TYPE_RLRLRL;//PCM_DATA_TYPE_LRLRLR; PCM_INFO_FILE_SIZE(&info) = 7680L*2; PCM_INFO_CHANNEL(&info) = 0x01; PCM_INFO_SAMPLING_BIT(&info) = 16; PCM_INFO_SAMPLING_RATE(&info) = 7680L; PCM_INFO_SAMPLE_FILE(&info) = 7680L*2; pcm = createHandle(&para); PCM_SetPcmStreamNo(pcm, 0); PCM_SetInfo(pcm, &info); PCM_ChangePcmPara(pcm); PCM_MeSetLoop(pcm, 7680L); if (pcm == NULL) { return; } PCM_Start(pcm); while(1) { SN76496Update(&g_movie_buf[delta],128); delta+=256; frame++; if(frame==60) { frame=0; delta=0; } PCM_Task(pcm); } }

   RockinB Nov 18, 2006 
That's cool, thanks a lot, vbt! Some portions of SBL code remind me of the AIF playback stuff.

   vbt Nov 18, 2006 

  RockinB said:
That's cool, thanks a lot, vbt! Some portions of SBL code remind me of the AIF playback stuff.


Sure but I found your code "hard" to read also I had no problem to read AIF/Tone/SEQ using samples. I didn't manage to read raw PCM with the SBL because of wrong settings and no sample for this.


About your idea to make a MOD/MP3,etc player, my code could help but ADPCM libs are more interesting. Instead of calling pcm_AudioMix it uses pcm_AudioAdpcmSct.


pcm_AudioAdpcmSct calls ADP_DecStereo/ADP_DecMono to play files. Unfortunatly the sources are not given with the SBL.


I have to check DUK sound play maybe there are specific sound functions.


So I'd say the good way would be to define PCM_ID and extend the PCM lib to play new format(easy to say ) with the same way as pcm_AudioAdpcmSct.


Here are PCM_IDs of the SBL :


PCM_ID_AIFF 'AIFF'

PCM_ID_AIFC 'AIFC'

PCM_ID_FORMAT_VERSION 'FVER'

PCM_ID_COMMON 'COMM'

PCM_ID_FORM 'FORM'

PCM_ID_SOUND_DATA 'SSND'

PCM_ID_ADPCM 'APCM'

PCM_ID_MARKER 'MARK'

PCM_ID_INS_TRUMENT 'INST'

PCM_ID_MIDI_DATA 'MIDI'

PCM_ID_AUDIO_RECORDING 'AESD'

PCM_ID_APPLICATION_SPECIFIC 'APPL'

PCM_ID_COMMENT 'COMT'

PCM_ID_NAME 'NAME'

PCM_ID_AUTHOR 'AUTH'

PCM_ID_COPYRIGHT '(c) '

PCM_ID_ANNOTATION 'ANNO'