Author Topic: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)  (Read 1658 times)

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #15 on: June 25, 2018, 08:38:40 pm »
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?

Code: [Select]
#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(&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);
//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.

Code: [Select]
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...
« Last Edit: June 26, 2018, 12:05:14 am by ponut64 »

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #16 on: June 26, 2018, 12:15:33 am »
I don't think the CD needs to be formatted as Mode 2 Form 2. I'm pretty sure this is only for Photo/Video CDs.
When you say commenting out one of the XA key lines makes the program work in SSF, does that mean it plays sound?

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #17 on: June 26, 2018, 12:45:15 am »
It doesn't play sound, but the Stream program does work. I am assuming if SSF would do that, then real hardware would. (Because when SSF didn't, real hardware didn't even if other emulators did)

I really think since it isn't playing ANY sound right now, I am either setting up the PCM play info completely wrong (which is weird, since Sega samples set it up like that, but also they don't work when I compile them either! when sent at PCM or ADPCM files!) OR I am sending the stream to the wrong address. I really do not know where I am supposed to put the data to play it back as a PCM file.

I tell ya what, if SGL had ADPCM, that would be really sweet because SGL is a helluva lot simpler to work with than SBL so far. Better documentation, less verbose code.
Unfortunately I am stuck with SBL since even if I could grab an ADPCM decompression program (in C) off the 'net, the point is to be able to stream it from the CD in some fashion.
I did find a M68K decompression program but listen, I barely understand what a "while" loop is, let alone live program addresses between two different CPUs through the SCU and SCSP.

Also, for a fun way to annihilate your ears, use the jo engine audio demo to try and playback ADPCM files.
... It's not fun. Heh.
« Last Edit: June 26, 2018, 01:07:44 am by ponut64 »

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #18 on: June 26, 2018, 01:38:22 am »
After looking at your code I noticed a few things off about it. So I made some adjustments to it. Please review it.
Code: [Select]
#ifndef __AUDIO_H__
#define __AUDIO_H__

#define SECTOR_SIZE     (2324L)
#define RING_BUF_SIZE  (2324L*10)
#define PCM_ADDR  ((void*)0x25a20000)
#define PCM_SIZE  (4096L*4)

#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(&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);
//SET PCM INFO FOR ADPCM
typedef struct  {
    PCM_INFO_FILE_TYPE;
    PCM_INFO_DATA_TYPE;
    //  Sint32 file_size;           how big is your file in bytes?
    //  Sint32 channel;             how many channels does your file have? '1' if mono '2' if stereo.
    //  Sint32 sampling_bit;        based on your comment I think this is 16.
    //  Sint32 sampling_rate;       in your case this is 18900.
    //  Sint32 sample_file;         I think this is asking for how many samples are in your file. In order to check this
    //                                         use a program like audacity.
    //  Sint32 compression_type;    I don't actually know what this is asking for and have no idea what to put here. 
}   PcmInfo;
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();

}

Also if ADPCM doesn't work out for you in the end I'd probably just try to play AIFF files(Seems a lot easier to play compared to ADPCM) or even CD-DA files if your project allows it.

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #19 on: June 26, 2018, 02:21:13 am »
That is a good catch that they are asking for number of samples. I know so little about audio files. What we need the number of samples for is to determine how long to play the file.

Changing
PCM_INFO_FILE_TYPE(&info) = PCM_FILE_TYPE_NO_HEADER;
to
PCM_INFO_FILE_TYPE(&info) = PCM_FILE_TYPE_AIFF;
makes the stream read more of the file specified, if that means anything.

I just haven't got it to make any sound so far.
AIFF or CDDA really is not an option ATM (unless I can 'accept' 6 KHz music..) because I need time free on the CD system.
Of course it's entirely possible I have the bandwidth capabilities of the CD system grossly underestimated, but I'm pretty sure we are working with somewhere in the realm of 768 bytes per frame (at 30 FPS). Program-controlled by GFS inside each program's frame of course. The idea is to get music files that can be read 256 bytes or less to get the sound in time each frame.

The reason that could be heavily understated is because the Saturn can obviously play 44.1KHz redbook audio.
I'm more concerned about A-bus/SH1 saturation, because of course the Saturn's CD-ROM is X2 speed and thus should be able to spit out around 5 KB per frame (300 KB/s).
Maybe I should just do more testing on the fetch speed.
Still it would be nice to get ADPCM to free up more time on the CD system to do other things.

/e: Okay, So. 2048 bytes per frame works. I do not know what was happening that made that slow-down at one point. Maybe a bad burn? Man, that makes things a lot faster.
I might be able to use 16 KHz mono PCM then.
I only estimate need of the CD for the following things:
- Area data (Level - paths - visibility - item data - etc)
- SFX (PCM at leisure, and needed much less often)
- ZTP (Binary model files and textures)
- Music

My plan has always been to segment these into different buffers that can have reads to them activated or deactivated at any time, with overlapping requests being simultaneous fetch, interleaved CD reads. I guess that is unncessarily complicated; it should all be interleaved reads & fetch, allowing every read data type to be using full bandwidth.

... I'm not giving up on pursuing SBL PCM though. I want it to make SOUND ! Sure, Jo engine can already do that...
« Last Edit: June 26, 2018, 02:40:05 am by ponut64 »

XL2

  • Sr. Member
  • ****
  • Posts: 350
  • Karma: +81/-1
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #20 on: June 26, 2018, 04:55:05 am »
For sounds I already got the tone data fully working, so it's all on sound ram now.
For CDDA, I'm not sure if you know, but it bypasses the system fully (DAC), so it doesn't use the A bus and uses no system ressources (well, maybe the SH1, but you can't do anything with it) .
Good job so far with your tests!

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #21 on: June 26, 2018, 06:08:13 am »
That's what I thought but I didn't know for sure.
I always assumed the A bus was slower than the system could process from, maybe it is maybe it isn't.

I will probably give up on SBL in a day or two but I will keep poking at it tomorrow
« Last Edit: June 26, 2018, 06:10:01 am by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #22 on: June 26, 2018, 11:27:39 pm »
My guess at this point is in order to use the SBL PCM-ADPCM library, you have to set up an SBL program (rather than an SGL program).
And that is much more complicated than SGL, since you must manage the system interrupts (like a DOS program, but worse).
That's something that will make a lot of other things break, so I am abandoning this quest.

I will post back here when I get PCM streaming under SGL working, though.
I am happy I could at least get some code to compile.


ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #23 on: June 27, 2018, 05:33:24 pm »
Nevermind.

SGL seems completely unable to properly playback anything different from 44.1 KHz PCM. Nowhere can you set the bitrate...
That makes things extra difficult. It looks like I have to figure out the PCM-ADPCM SBL library, one way or another...
Why is sound such a pain in the ass?

thankfully, the Rockin' B might come to the rescue with Saturn Sound Player. It mixes SBL and SGL PCM libraries so he proves it's possible.
« Last Edit: June 27, 2018, 06:04:41 pm by ponut64 »

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #24 on: June 27, 2018, 09:06:57 pm »
Yeah. Rockin'B's sound player definitely proves that mixing the two libraries is possible, but when I looked through the source code I found the player only plays AIF and Adpcm that already have a header. I think for now you should see if you can get AIFs to play as that seems a lot easier to playback compared to XA audio, but that's for you to decide.  :)

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #25 on: June 27, 2018, 09:47:38 pm »
AIFFs do play (not with 'my SBL' yet... may it be damned), they are formatted identically to Saturn PCM as far as I can tell. (They just have a header)
Using AIFFs is the simplest of any variety as far as converting the files.
But I have put in the SBL init functions and SGL still plays sound, so that should at least indicate that SBL would play sound whenever I actually got the stupid stuff to work.
SGL still doesn't play them back at the correct rate.

It's funny how the documentation says
Quote
The PCM-ADPCM Playback Library enables simplified playback of PCM audio on the
SEGA SATURN
Yes, "simplified"
I am humoring myself don't worry
« Last Edit: June 27, 2018, 09:53:09 pm by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #26 on: June 29, 2018, 05:59:45 pm »
Well I had a day where I couldn't work on it, so now I don't remember what did and what didn't produce 'results' with SBL.

But I would like to let nobody know that the code is still freezing at "PCM_Task".
Trying to use GFS handles with AIFF files.
I do know it is the handle because if I use a bad file-name, it doesn't get stuck (but obviously, it doesn't play sound).
So if I figure out what's crashing or freezing it, maybe I will get it to make sound.
--> And I am no longer using jo engine callback (though it doesn't behave differently with or without it so far)
« Last Edit: June 29, 2018, 06:03:01 pm by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #27 on: June 30, 2018, 08:44:07 am »
I'd like to share something that might be important.

Here is a structure to get some error codes:

Code: [Select]
PcmErrCode pcmsysErr = PCM_GetErr();
jo_printf(0, 19, "(%x)", pcmsysErr);
PCM_Task(pcm);

What could these codes be?

Code: [Select]
/* エラーコード	*/
typedef enum {
PCM_ERR_OK = 0x00000000,/* エラーは発生していない */

/* PCM_Create のエラー */
PCM_ERR_OUT_OF_HANDLE = 0x00000101,/* ハンドル売り切れ */
PCM_ERR_NO_INIT = 0x00000103,/* 初期化関数がコールされてない */

/* PCM_Destroy のエラー */
PCM_ERR_INVALID_HN = 0x00000201,/* 不正なハンドルで消去 */
PCM_ERR_ILL_CREATE_MODE = 0x00000202,/* Create 時のモードと違う */

/* pcm_HeaderProcess のエラー */
PCM_ERR_TOO_LARGE_HEADER = 0x00000302,/* ヘッダがき大すぎる */
/* (バッファサイズが小さすぎる) */
PCM_ERR_HEADER_DATA = 0x00000303,/* ヘッダデータエラー */
PCM_ERR_TOO_SMALL_PCMBUF = 0x00000304,/* PCMバッファサイズが小さすぎる */
PCM_ERR_ILL_SIZE_PCMBUF = 0x00000305,/* PCMバッファサイズ不正 4096*2~16 */
PCM_ERR_AFI_NO_COMMON = 0x00000306,/* CommonChunk が無い */
PCM_ERR_AFI_COMMPRESS = 0x00000307,/* 未対応圧縮タイプ */
PCM_ERR_NOT_DECLARE_ADPCM = 0x00000308,/* ADPCM使用宣言がない */

/*  */
PCM_ERR_ILLEGAL_PARA = 0x00000503,/* 引き数の指定が間違っている */
PCM_ERR_ILLEGAL_HANDLE = 0x00000504,/* ハンドルが異常 */

/* 連続再生に関するエラー */
PCM_ERR_NEXT_HN_STATUS = 0x00000601,/* 連続再生ハンドルの状態異常 */
PCM_ERR_NEXT_HN_AUDIO = 0x00000602,/* オーディオの条件が一致しない */
PCM_ERR_CHANGE_NO_ENTRY = 0x00000605,/* エントリがない状態でチェンジ */

/* ポーズに関するエラー */
PCM_ERR_PAUSE_STATUS = 0x00000701,/* PCM_STAT_PLAY_TIME, または、
* PCM_STAT_PLAY_PAUSE 以外の
* 状態でポーズ関数をコールした。
*/
PCM_ERR_PAUSE_WORK_NULL = 0x00000702,/* ポーズ処理用ワーク異常 */
PCM_ERR_PAUSE_WORK_SIZE = 0x00000703,/* ポーズ処理用ワーク異常 */
PCM_ERR_PAUSE_WORK_SET = 0x00000704,/* ポーズ処理用ワーク指定が不正*/

/* DMA転送に関するエラー */
PCM_ERR_DMA_MODE = 0x00000801,/* 未対応の転送方式 */
PCM_ERR_DMA_CPU_PCM = 0x00000802,/* DMAが異常終了 */

/* ファイル読み込みエラー */
PCM_ERR_GFS_READ = 0x00000901,/* GFSの読み込みで失敗 */

/* リングバッファへのデータ供給に関するエラー */
PCM_ERR_RING_SUPPLY = 0x00000a01,/* 再生完了後に供給があった    */
/* (供給が間に合わす中断した)*/

PCM_ERR_END
} PcmErrCode;

I am currently facing Error 303. Header data error. Hmm...
I wonder if... it's not reading the header correctly?
I wonder if... my files simply do not have the correct header data for the Saturn to read? Any period-correct (like Apple / Basilisk II compatible) WAV / MP3 to AIFF converters you guys know of?
« Last Edit: June 30, 2018, 08:50:21 am by ponut64 »

XL2

  • Sr. Member
  • ****
  • Posts: 350
  • Karma: +81/-1
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #28 on: June 30, 2018, 04:53:25 pm »
Did you manage to load your aiff files in the Sega sound tools?
Check this out first.
Also, modern aiff don't have the same endianness as older versions, so that's also an issue.

ponut64

  • Full Member
  • ***
  • Posts: 182
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #29 on: June 30, 2018, 07:17:32 pm »
No, actually... I don't know what sound tool is relevant to this, and how to even open them.
The PCM to ADPCM (XA?) converter converts them and correctly reports their bitrate and such correctly, though that doesn't mean anything about what Saturn hardware would read.
Every program of "Sound tools" in the Macintosh section of the documentation site opens with errors.

From the documentation, it looks like they expect you to have a Saturn dev kit for any of it to work. Obviously I don't have one of those.
« Last Edit: June 30, 2018, 07:32:40 pm by ponut64 »

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk