Starting Out in Audio
Starting Out in Audio
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.
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! :)
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! :)
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
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
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: Select all
/*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
}
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