forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ATRAC3 Player Sample
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
patpsp



Joined: 25 Oct 2005
Posts: 31

PostPosted: Thu Apr 27, 2006 10:28 pm    Post subject: Reply with quote

Very interesting !!

Do you think, it can be easy to use in the future ? For example, simple functions in the pspsdk like at3_init(), at3_play(char * music), at3_stop() ?

I've tried your sample n°2, it works like a charm :)
Just a little bug, when i browse to the music it has detected, some music are shown in 2 lines, and the selection with up and down, doesn't work properly.

Do you have an idea whether this lib can be less CPU demanding than libmad, or perhaps, whether it uses the ME ?

Is at3 format legal ?
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Fri Apr 28, 2006 2:59 pm    Post subject: Reply with quote

it does indeed use 0% zero load on main cpu/allegrex
...why?..because libatrac3 uses the ME to handle the
load so this is by far the best remedy for those looking
for background music to add to their games ...and it
works a treat :)

as for creating your own library of at3_play() etc...
that shouldnt be a problem for you at all ...i mean
i wonder what this does
Code:
void playAT3File(char *file)

;)
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
patpsp



Joined: 25 Oct 2005
Posts: 31

PostPosted: Fri Apr 28, 2006 6:40 pm    Post subject: Reply with quote

I'm not sure whether i understand your answer.
My question was about the the possibility to write a library like libmad, using the libatrac3 stuff, integrated to the pspsdk.
When i look at the moonlight's sample 2, I see that it generates a prx module, which is not easy to implement in another project.

From what i understood, this library would consist on :
(i simplify the functions, I just want to understand whether this could work or not)
Code:

- int Init_AT3() :
  // load necessary modules
  pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
  pspSdkLoadStartModule("flash0:/kd/libatrac3plus.prx", PSP_MEMORY_PARTITION_USER);
        return 1;

- int playAT3File(char *file) :
  // generate a thread, and return his id
  int playth = sceKernelCreateThread("play_thread", play_thread, 0x12, 0x10000, PSP_THREAD_ATTR_USER, NULL);

  if (playth >= 0) sceKernelStartThread(playth, strlen(file)+1, file);
  return playth;

- int stopAT3File(int id) :
  sceKernelDeleteThread(id);
Back to top
View user's profile Send private message
patpsp



Joined: 25 Oct 2005
Posts: 31

PostPosted: Sun Apr 30, 2006 6:08 pm    Post subject: Reply with quote

Sorry, to post again here, but I really think this libatrac3 can really be a must in homebrew devs.

Do someone currently work on the full pspsdk integration of this lib ?
Back to top
View user's profile Send private message
pspwill



Joined: 17 Nov 2005
Posts: 51

PostPosted: Sun Apr 30, 2006 7:32 pm    Post subject: Reply with quote

do you think we could use the same method of this to play the video off of umd videos?
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon May 01, 2006 3:29 pm    Post subject: Reply with quote

read the source people!
you can easily integrate this into your
own homebrew! ...its all there and there is
already pspatrac3.h in pspsdk !

pspwill: umd videos do use this format for audio
but the video container still needs to be parsed
and so that is not a possibility right now ...but when
more about pmf is learned no problem ;)
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Mon May 01, 2006 4:10 pm    Post subject: Reply with quote

i did some mods to this:
-Added support to write at3 decoded data
to uncompressed wav
-Added selection between play only and
saving decoded data to wav
-Added a playlist mode
-extended buffer to 12mb

http://weltall.consoleworld.org/PSP/AT3PLAYERMOD02.rar
Back to top
View user's profile Send private message Visit poster's website
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon May 01, 2006 4:12 pm    Post subject: Reply with quote

nice playlist mod :)
that is what people should be doing
good work
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Mon May 01, 2006 4:45 pm    Post subject: Reply with quote

Some more functions:

Code:

/**
 * Gets the number of samples of the next frame to be decoded.
 *
 * @param atracID - the atrac ID
 * @param outN - pointer to receives the number of samples of the next frame.
 *
 * @returns < 0 on error, otherwise 0
 *
*/
int sceAtracGetNextSample(int atracID, int *outN);

/**
 * Gets the maximum number of samples of the atrac3 stream.
 *
 * @param atracID - the atrac ID
 * @param outMax  - pointer to a integer that receives the maximum number of samples.
 *
 * @returns < 0 on error, otherwise 0
 *
*/
int sceAtracGetMaxSample(int atracID, int *outMax);


I hope someone with access to the svn adds them to pspatrac3.h

Rewritten the sample with the use of sceAtracGetMaxSample to find the appropiated channel size.

This ugly code:

Code:

// VERY UGLY way to find an appropiated channel size
   t1024 = 0;
   t2048 = 0;

   for (i = 0; i < 20; i++)
   {
      int nsamples, end, rem;

      sceAtracDecodeData(atracID, blocks[0], &nsamples, &end, &rem);

      if (nsamples == 1024) t1024++;
      else if (nsamples == 2048) t2048++;
   }

   sceAtracReleaseAtracID(atracID);
   atracID = sceAtracSetDataAndGetID(file_buffer, fsize);

   if (atracID < 0)
   {
      debugMessage("Unknown error.\n");
      return -1;
   }

   if (t1024 > t2048)
      chsize = 1024;
   else
      chsize = 2048;


replaced with a simple line :)
Code:

sceAtracGetMaxSample(atracID, &chsize);


http://www.megaupload.com/?d=87UL06DC


Next thing is try to find the way of at least playing the sound from pmf files.


Last edited by moonlight on Mon May 01, 2006 8:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon May 01, 2006 6:34 pm    Post subject: Reply with quote

:)
buggy bug report:
when playing a atrac3 file from video umd
located at this location disc0:/UMD_VIDEO/SND0.AT3
it will playback once then again when user selects to
playback only once then it will stop after playback 2x

thought youd like to know
nice big improvement in source :)
_________________
10011011 00101010 11010111 10001001 10111010


Last edited by dot_blank on Mon May 01, 2006 6:51 pm; edited 2 times in total
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Mon May 01, 2006 6:47 pm    Post subject: Reply with quote

Added the new functions to the sdk.
Back to top
View user's profile Send private message
patpsp



Joined: 25 Oct 2005
Posts: 31

PostPosted: Mon May 01, 2006 6:56 pm    Post subject: Reply with quote

dot_blank wrote:
read the source people!
you can easily integrate this into your
own homebrew! ...its all there and there is
already pspatrac3.h in pspsdk !


I've read the source, and my question shows it.
This forum is about "Homebrew PS2 & PSP Development Discussions", so I suppose that I can ask questions, hoping that someone could answer and help. If it is easy for you, why not sharing your knowledge ? Isn't the aim of this forum ?
Back to top
View user's profile Send private message
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Mon May 01, 2006 7:56 pm    Post subject: Reply with quote

after this sceAtracGetMaxSample(atracID, &chsize);
you can find sceAtracSetLoopNum(atracID, 1);
replace with sceAtracSetLoopNum(atracID, 0);

and it replay only one time
thanks to dot_blank


Last edited by weltall on Tue May 02, 2006 5:45 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Mon May 01, 2006 8:08 pm    Post subject: Reply with quote

weltall wrote:
after this sceAtracGetMaxSample(atracID, &chsize);
you can find sceAtracSetLoopNum(atracID, 1);
replace with sceAtracSetLoopNum(atracID, 0);

and it replay only one time
thanks to dot_black


thanks :) updated the link with that fix and using the new definitions in the pspatrac3.h header.
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon May 01, 2006 8:30 pm    Post subject: Reply with quote

patpsp: what is your question exactly?
what is your error, what do you want to accomplish?

if its just playing back an atrac3 file the source has
obvious atrac3 playback function and buffer setup

you need to help me to help you
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
patpsp



Joined: 25 Oct 2005
Posts: 31

PostPosted: Mon May 01, 2006 8:50 pm    Post subject: Reply with quote

Thanks dot_blank to be more comprehensive. I really appreciate this.

My question was about the possibility to make a library like libmad, which handles all needed for reading atrac3.

The goal is to be able to link any homebrew to this library and use simple functions like libmad offers.

I proposed a prototype some posts ago, and just wanted to know whether it could work.

Code:


- int Init_AT3() :
  // load necessary modules
  pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
  pspSdkLoadStartModule("flash0:/kd/libatrac3plus.prx", PSP_MEMORY_PARTITION_USER);
        return 1;

- int playAT3File(char *file) :
  // generate a thread, and return his id
  int playth = sceKernelCreateThread("play_thread", play_thread, 0x12, 0x10000, PSP_THREAD_ATTR_USER, NULL);

  if (playth >= 0) sceKernelStartThread(playth, strlen(file)+1, file);
  return playth;

- int stopAT3File(int id) :
  sceKernelDeleteThread(id);


Thanks for your help.
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon May 01, 2006 9:08 pm    Post subject: Reply with quote

main.c of PRX of atrac3 sample has all the
functions that you should need and creating
your own library is a real snap just create your
own lib with functions in source .c files and the
proper prototypes in a similar named header file
then of course include that header file in your source
.c file and then then include header file in your app
...all functions are there all you have to do is extract
them and alter to your liking ....do not extract the
obvious thread stuff like play_thread as that
should be user specific for whichever app you
are working on

...play around with it and youll see creating your own
library is a snap ...if you dont get it by a weeks end
then maybe someone will provide a easy ready made
library ;)
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Mon May 01, 2006 9:41 pm    Post subject: Reply with quote

About the perfomance... I've set the processor to only 12/6 Mhz and it's playing fine :)) The search of files is slower, but the play is really good :)
Back to top
View user's profile Send private message
__count



Joined: 23 Mar 2006
Posts: 22

PostPosted: Mon May 01, 2006 9:59 pm    Post subject: Reply with quote

moonlight wrote:
About the perfomance... I've set the processor to only 12/6 Mhz and it's playing fine :)) The search of files is slower, but the play is really good :)


That's awesome :)

Do you think it would be difficult to stream at3's (instead of loading the whole thing in a static buffer)?
Back to top
View user's profile Send private message
patpsp



Joined: 25 Oct 2005
Posts: 31

PostPosted: Mon May 01, 2006 10:02 pm    Post subject: Reply with quote

dot_blank -> thanks for answer. I'm trying. Do you think i can totally achieve in not using the prx stuff ?

moonlight -> very good news. thanks again for your work.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Tue May 02, 2006 12:24 am    Post subject: Reply with quote

__count wrote:
moonlight wrote:
About the perfomance... I've set the processor to only 12/6 Mhz and it's playing fine :)) The search of files is slower, but the play is really good :)


That's awesome :)

Do you think it would be difficult to stream at3's (instead of loading the whole thing in a static buffer)?


It has to be possible. The game that i reversed didn't load the whole file, but only a part, and then add more data to the buffer, i have to do some more reverse on that, there are a lot more of functions in libatrac3plus.
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Tue May 02, 2006 5:35 am    Post subject: Reply with quote

streaming would be probably top of my list :)
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Thu Jun 15, 2006 12:44 am    Post subject: Reply with quote

Hi,

I had a question: Is atrac3 usable for sound effects? i mean doing mp3 for this is not usable due to the late play response, wav however almost executes directly so that would be good (if there were libraries existing...) so is atrac3 faster then mp3?

greets Ghoti
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
zilt



Joined: 21 Feb 2006
Posts: 45
Location: Ontario, Canada

PostPosted: Thu Jul 13, 2006 4:22 am    Post subject: Reply with quote

moonlight: Any luck with figuring out atrac3 streaming? I'm adding music/sound support to my 3d world ( www.antimass.org/zilt ) based on your atrac3sample3.zip and the streaming would help free up memory. Thanks,

Zilt
_________________
"We are dreamers, shapers, singers, and makers. We study the mysteries of laser and circuit, crystal and scanner, holographic demons and invocations of equations. These are the tools we employ and we know... many things." -- Elric, B5
Back to top
View user's profile Send private message Visit poster's website
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Thu Jul 13, 2006 7:36 pm    Post subject: Reply with quote

I see that it loads some roms from the flash. Is there any chance of bricking if my program crashes cos of this? (just got my psp so I'm in that 'too scared to run almost anything incase it bricks my psp' phase)
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Thu Jul 13, 2006 7:56 pm    Post subject: Reply with quote

Loading modules from the flash won't destroy your psp. It's what the firmware is constantly doing, the modules of the firmware are not loaded by magic.

That's what i call paranoia in its maximum level.
Back to top
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Thu Jul 13, 2006 8:05 pm    Post subject: Reply with quote

I didn't actually know modules were loaded from flash, like I said I just got my psp so it's all new to me.
Back to top
View user's profile Send private message
zilt



Joined: 21 Feb 2006
Posts: 45
Location: Ontario, Canada

PostPosted: Thu Jul 13, 2006 9:36 pm    Post subject: Reply with quote

Nevermind about the streaming - I've worked around it by adding a separate thread that keeps a double buffer filled ( reduced the internal buffer down to 512k for dual atrac3 streams). I've also found that I can blend 2 concurrent atrac3 samples ( on separate channels ) with almost no drop in 3d framerate.

When I try starting a third atrac stream, I get 0x80630003 from sceAtracSetDataAndGetID() which I'm assuming means no more atrac streams left or something.

I also changed the dual producer/consumer thread pattern into a single thread ( though each atrac stream is it's own thread ). Thanks very much again for the atrac3 sample. I'll be releasing all my client code ( and keeping it in a svn repos ) after the next release.
_________________
"We are dreamers, shapers, singers, and makers. We study the mysteries of laser and circuit, crystal and scanner, holographic demons and invocations of equations. These are the tools we employ and we know... many things." -- Elric, B5
Back to top
View user's profile Send private message Visit poster's website
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Fri Jul 14, 2006 5:05 am    Post subject: Reply with quote

Sorry, I forgot totally to continue researching the atrac3 library since i was busy with other things.

The last thing i remember was looking to a couple of functions, sceAtracAddStreamData and other that i don't remember now.

I remember also that the addstreamdata was not what i expected. I expected a pointer in its parameters, but all of them were integer.

I hope this can help someone wanting to finish the job.
Back to top
View user's profile Send private message
subbie



Joined: 05 May 2005
Posts: 122

PostPosted: Sun Jul 23, 2006 8:28 pm    Post subject: Reply with quote

I have a somewhat stupid question.

Can this...

pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
pspSdkLoadStartModule("flash0:/kd/libatrac3plus.prx", PSP_MEMORY_PARTITION_USER);

be executed in an app that is in user mode or must I launch it the same way the demo does?

For some reason my code crashes around thies lines and my app is just in user mode.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group