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 

Starting Out in Audio

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Vincent_M



Joined: 03 Apr 2007
Posts: 73

PostPosted: Sat Sep 01, 2007 2:34 am    Post subject: Starting Out in Audio Reply with quote

I've seen the source to loading aac, at3, the at3mod, and some other source code, but it's still a bit too complex for me at the moment in terms of working with audio. My end goal is to be able to load and play (stream) at3 files on a separate thread using the Media Engine. I need to do a little work on threading, because I haven't worked with threading on the PSP before, and I have no audio programming experience at all. Saying that, I know I won't be able to do anything too seriousely just yet. What I'm looking for right now is some sources to completely load and play music. I'm not looking for any tutorials, or code (I've got plenty of demo code), but simply just some advice where to start, I know there's a lot to know before I get into anything huge, so I'm just looking for opinions/suggestions on where to start. I've been researching a little on how certain file formats such as the wav format, and how compression works with the mp3 format. I haven't been able to find any useful information on the at3 format, but I've heard that it is easier to use than the mp3 format. I've looked through pspaudio.h, pspaudiolib.h, and pspaudiocode.h, but I don't have any luck on where to go in terms of learning how to load sound data from files in a way that the PSP can use to produce sound on the PSP speakers.
Back to top
View user's profile Send private message
Energy



Joined: 26 Mar 2005
Posts: 133
Location: uk/beds/flitwick

PostPosted: Tue Sep 04, 2007 5:19 am    Post subject: Reply with quote

I'm not an audio guy, so I hope this info is correct.

First off the best place to start learning audio is in the SDK samples (surely?) there is a WAVE generator there. It'll create a nice sinewave that if you put high enough will give you a headache in a few seconds. ;) this should give you an idea on how to interface with the PSP's audio hardware.

It may also have some examples of threading there, possibly some ME stuff. I know that there are a few ME samples floating about.

Secondly as for decoding atract stuff there is another thread about that someone found firmware calls to decode atrac and mp3 via the firmware. chances are that these are using the ME(?), or that they're going pretty well so trying to make it work faster maybe a challenge. I don't know tho!

Good luck in whatever you're up to! :)
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Thu Sep 06, 2007 1:11 am    Post subject: Reply with quote

cooleyes is your guy for at3/mp3/acc sample

as for goal of producing sound with efficient
memory usage do research more on DOUBLE BUFFERS

struct AUDIO_BUFFER aud_buff[2] ; // thats two buffers

take same aspect as draw/display buffers for graphics
and utilize FLIPPING those buffers, constantly filling them
Code:

/*c++*/
for(i=0; i < 2; ++i) {
    if( i > 1 )  i = 0; // remember array is [0, 1]

    aud_fill_buffer( aud_buf[ i ] ) ; // try and always fill 32KB of data from
                                    // FILE* tip: just use pointer arithmetic
                                    // to increment always by an aligned
                                    // buffer struct that is 32KB
    aud_play_buffer( aud_buf[ i ] ) ;
    aud_buf[ i ] = aud_flip_buffer() ; // safer
   
}

// ** this is only if you want to be clever **
#define AUD_BUFF_START (0)
#define AUD_BUFF0  (0)
#define AUD_BUFF1  (1)

char cur_buff = AUD_BUFF_START ;
switch( cur_buff ) {
   case AUD_BUFF0 :
         // do your filling of this buffer_0
         // @ end ; do NOT free instead just refill buffer_0 = NULL ;
         // this can be optimized out
        aud_buff[1] = aud_buff[0] ;
        aud_buff[0] = NULL ;

        cur_buff = AUD_BUFF1 ; // OR you could FALL thru 
   case AUD_BUFF1 :
         // do your sending buffer_0 to buffer_1 and then send to audio system
         // @ end ;
        cur_buff = AUD_BUFF0 ; // start process all over again
    default : cur_buf = AUD_BUFF_START ; // f*ck exceptions ;P
}


once you got filling two buffers out of the way then really
look into MUTEX and semaphores and a queue system
to help keep locking things out like artifacts, threads getting into memory usage etc...

as for THREADING, look into POSIX threads and how threads
work together once they understand their priorities
hey one day you could even do double threads that each handle their
OWN buffer from the aud_buff[] array, then your guranteed they never
mix up which of 0 or 1 they should be handling

just make sure threads are highest priority if you utilize a PAUSE menu
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Vincent_M



Joined: 03 Apr 2007
Posts: 73

PostPosted: Thu Sep 06, 2007 12:36 pm    Post subject: Reply with quote

Awesome example for streaming! I'll ask cooleyes on how to feed music data to the PSP's ME.
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
Page 1 of 1

 
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