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

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
/e: Nevermind, I seem to have fixed it!

Regardless for anyone who wants to use ADPCM, here is an updated LIBPCM.A and an updated jo engine makefile.

For anyone curious as to what the problem was, there's no SBL source code for ADPCM system. There is however LIBADP, which contains the object code for said functions, and they are in fact linked in the code its just there's no source.

So I downloaded SaturnOrbit and simply included the .o files in LIBPCM.A -- you shouldn't need LIBADP.A anymore, but it is there in any case.

You put LIBPCM.A in
\joengine-master\Compiler\SGL_302j\LIB_COFF
Keep your old LIBPCM! Who knows what I have broken!
You also should put the following line in your Jo engine makefile
JO_COMPILE_USING_SGL = 1
**IT SHOULD BE NOTED THIS IS THE SBL PCM LIBRARY, NOT SGL
« Last Edit: June 22, 2018, 07:27:08 pm by ponut64 »

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #1 on: June 23, 2018, 12:00:56 am »
Awesome work ponut64! Hopefully this will be able to make more people use the SBL ADPCM library now.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #2 on: June 23, 2018, 02:02:46 am »
Thanks, I should be working with 22 KHz ADPCM in the following days.
It's really impressive since 22 KHz ADPCM is the same file-size as 44.1 KHz mp3 files.
Sure, half as compressed as mp3 files, but the Saturn can handle it.

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #3 on: June 23, 2018, 02:31:31 am »
22 khz ADPCM is pretty impressive. You save quite a lot of space with it compared to Redbook audio and it doesn't sound that bad either.
Only problem with it is the amount of CPU overhead it takes.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #4 on: June 23, 2018, 04:24:46 am »
I'm not sure if we should be at all concerned with the CPU overhead, since I am pretty sure they are referring to the M68K which is dedicated to sound. You also probably don't need stereo for music, and using mono will cut the CPU usage in half.
If that isn't the case, then certainly, 20% of your work area CPU grunt being eaten up by music would be alarming.
You wouldn't have to worry about that overhead unless you were using a lot of special effects on many different PCM channels.
Which I suppose you could!
« Last Edit: June 23, 2018, 04:30:34 am by ponut64 »

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #5 on: June 23, 2018, 04:48:54 am »
I thought the CPU overhead they were referring to was one of the SH2 processors.
It would be a relief if they were talking about the M68k processor, but if that's the case then what's stopping you from doing 44khz ADPCM? It is only has about 30% CPU overhead.(What else would the M68k processor be doing besides this?)

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #6 on: June 23, 2018, 11:27:55 am »
I'm not planning on 44 KHz ADPCM since that's too much data for the CD system (mostly the A bus) to handle simultaneously with the other tasks I have planned for it.
Assuming my ideas even work. They should though.
If you wonder what else might the M68K be doing, well there are 8 PCM sound channels and one could in theory be playing 44 KHz sound bytes on all of them.
Not just that, but let's say you processed some sort of reverb or echo in the program, that would involve some SH2 work but also the M68K too.

I guess once I get an ADPCM program implemented, someone might be able to probe the performance impact.

/e: Well, it would seem that the ADPCM decompression program is indeed using the SH2s to a significant extent (by looking over the source code). However, keep in mind the ADP library has no source code to be found and I imagine that's the case because its written in Assembly for the M68K. I don't know why I wonder so deeply when I can test it very soon.
Though it looks like it does a few back-and-forth transfers to sound RAM and if that's the case you're far more concerned about B-bus usage than anything else.
« Last Edit: June 23, 2018, 12:02:25 pm by ponut64 »

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #7 on: June 23, 2018, 02:49:01 pm »
The impact is mainly on SH2 as, as you said, we don't care about sound cpu usage since it doesn't do much.
The decompression is done in software.
Have you checked the SBL library to make sure it doesn't have the source code?
They also have the code for the sound cpus and drivers if I'm not mistaken.
AFAIK the compression ratio should be 1:4, which is quite nice.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #8 on: June 23, 2018, 07:47:33 pm »
Now I have a different problem.

Sega's documentation has stuff like this:
Code: [Select]
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);

The issue is, PCM_PARA_WORK references a member of the PCM_PARA struct (&para) called "work".
.. No such member exists.

This is a basic fact of SBL PCM playback and I am not sure of a way around it.

There's also a plethora of other issues, such as the SBL STM documentation stating some functions have have void inputs, but in fact don't. (Stream functions aren't entirely necessary, they just decided to make a usage example with the stream functions..)
I guess this is going to take longer than "a few days" to get working.

And to get any of this to compile, it's best you just include the entire SBL library in jo engine makefile.

It's really not clear how to use SBL PCM. Not clear at all!

/e: So, they did not specify what type "para" in the example. It turns out it is the type "PcmCreatePara", not "PcmPara".
I better do a little more research before I post this stuff on the forums eh?
« Last Edit: June 23, 2018, 10:15:50 pm by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #9 on: June 24, 2018, 02:44:17 pm »
It looks like this is another one of my "play-by-play" update threads.

So here is some code. It's errorless, but the sound does not play. I am not sure where to put the data in memory to get it to play.

Of course one must earlier plan out your GFS and also call the commands PCM_Init(); and     PCM_DeclareUseAdpcm();

Code: [Select]
#ifndef __AUDIO_H__
#define __AUDIO_H__

#define RING_BUF_SIZE  (2048L*10)
#define PCM_ADDR  ((void*)0x25a20000)
// The above seems to point somewhere in LWRAM.
#define PCM_SIZE  (4096L*2)
#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:
//load an ADPCM file from CD (GFS_Load)
//Set up a PCM memory handle using the loaded CD data
//--> Understand PCM_VblIn or otherwise SBL interrupt system
//Playback the PCM file from PCM memory handle

void adpcm_load(void){
/* Work  */
PcmWork pcm_work;
PcmCreatePara para;
/* Ring Buffer  */
Uint32  ring_buf[RING_BUF_SIZE / sizeof(Uint32)];
PcmHn       adpcm;
/* 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;
adpcm = PCM_CreateMemHandle(&para);
//Load
    void * soundAddress;
soundAddress = PCM_ADDR;
Sint8* name = "SHELL.ADP";
//Data of read structure
    Sint32 fid = GFS_NameToId(name);
GfsHn gfs;
Sint32 nsct;
Sint32 fsize;
//Data of read-in-process
Sint32 stat;
Sint32 rdsize;
//Destination address?
void * ptr2 = adpcm;
//Loading follows
gfs = GFS_Open(fid);
//Get sectors
//HEY! SBL DOCUMENTATION IS WRONG! THIRD ITEM nzect IS GFS SECTOR COUNT. SECOND ITEM IS CD SECTOR SIZE.
GFS_GetFileSize(gfs, NULL, &nsct, NULL);
GFS_GetFileInfo(gfs, NULL, NULL, &fsize, NULL);
//TIP: GFS_NwCdRead cannot be checked for completion. Sorry!
GFS_NwCdRead(gfs, fsize);
GFS_NwFread(gfs, nsct, (Uint32*)(soundAddress), fsize);
do{
GFS_NwExecOne(gfs);
GFS_NwGetStat(gfs, &stat, &rdsize);
jo_printf(0, 11, "(%i)", rdsize);
jo_printf(10, 11, "(fetched filesize)");
}while(stat != GFS_SVR_COMPLETED && rdsize < fsize);
// slDMACopy(soundAddress, ptr2, sizeof(PcmHn));
// slDMAWait();
/* Start Playback */
PCM_Start(adpcm);
while(TRUE) {
/* Playback task processing */
PCM_Task(adpcm);
/* End condition */
if (PCM_GetPlayStatus(adpcm) == PCM_STAT_PLAY_END) break;
}
/* Destroy Handle */
PCM_DestroyStmHandle(adpcm);
/* End Processing */
PCM_Finish();

}


i've also included some sample files
« Last Edit: June 24, 2018, 02:46:49 pm by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #10 on: June 24, 2018, 08:51:04 pm »
I really don't have a clue.

I can use the ADP_DecMono (decompress mono) function with the Jo engine PCM load function, which should work since it just outputs a decompressed PCM.
It compiles, it doesn't crash, but the sound doesn't play.
I am not sure what to do...

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #11 on: June 24, 2018, 09:58:43 pm »
Are you using the XA ADPCM audio encoder by Sega for Mac? If So then you need to use the function 'PCM_SetInfo'. The files the XA encoder outputs doesn't have a header
so you need to specify the audio information. Also I'm pretty sure you can only use Stream playback mode when using XA audio.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #12 on: June 24, 2018, 10:50:42 pm »
That is a thought, but this is converted AIFF files to ADPCM using a different tool (still a Mac tool though). The documentation refers to this as "User-specified ADPCM" (not the optimage thing, but referred at the bottom of this page as "ADPCM Encoder" https://antime.kapsi.fi/sega/docs.html). In that case, since the AIFF file has a header, so should the ADPCM file (it isn't discarded when compressed). It should be noted that if you try to playback the ADPCM file as a PCM file with Jo engine functions, you get sound, it's just garbage. T
Maybe CD-XA would work. The issue is I imagine that won't work over an .ISO file. The reason I've skipped over CD-DA is because Bizhawk, Yabause, and SSF won't accept files like that. Maybe it will work for CD-XA though I am no more certain on how to actually playback CD-XA than AIFF-ADPCM files seeing as the documentation tells you jack shit about how to do that. (I exaggerate, I just vehemently dislike their code example because it leaves so much up to imagination)
« Last Edit: June 24, 2018, 10:57:58 pm by ponut64 »

LackofTrack

  • Newbie
  • *
  • Posts: 25
  • Karma: +6/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #13 on: June 24, 2018, 11:09:41 pm »
 :) That is the Sega XA ADPCM encoder I'm taking about. It outputs a XA audio file with no header. So you are using XA audio. Also CD-XA has nothing to do with the fact that you are using an iso.
CD-XA will work perfectly fine in a iso.(CD-XA is within the iso itself. CD-DA is not actually in the iso. You have to use a cue file in order to tell the iso to use your CD-DA files.)
« Last Edit: June 24, 2018, 11:13:18 pm by LackofTrack »

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #14 on: June 24, 2018, 11:28:02 pm »
https://youtu.be/GD6qtc2_AQA

I am learned.

I didn't know that was the XA Audio encoder. It makes sense that it would be, it's the only one there, and they say the other one is from a 3rd party.
I'll have to move forward with SBL Stream system then!
I DID try that at one point, but it didn't work, but there's probably quite a few more reasons why it wouldn't that are explained since I need to figure out the stream library too.
And the header stuff. They say it should be filled in by the subheader?
Also, 22KHz ADPCM should not be possible with CD-XA. I'll have to re-do at 18.9 KHz right? (that only takes about 30 seconds)

Also, where's that other ADPCM encoder they mentioned?

More /e: There is a sample program for Stream playback, that's very good.
smppcm5.c in SBL
« Last Edit: June 25, 2018, 01:06:01 am by ponut64 »

 

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