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 

libSpeex and playback

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



Joined: 20 Sep 2006
Posts: 12

PostPosted: Wed Sep 20, 2006 6:41 am    Post subject: libSpeex and playback Reply with quote

Hi first time poster, long time reader.
I have been trying to figure out how to use the PSP Audio library so that I can use Speex to play some encoded file back. So far I have managed to get the library to compile and install into the SDK, modified a couple of the encoding and decoding sample programs to work on the PSP. These just take a wav file encode to spx and decode back to wav, no problems so I know my library works. However I just cannot seem to get the PSP to play back any audio, and since I have looked at every PSP Audio example I can find I cannot seem to get it to work. I guess I am missing something fundamental as most of the samples talk about using 1024 bits, whereas on average mine is producing 320 bits per callback, so I guess the sample rate is too low, but I cannot figure out what I am doing wrong.

You can download my libSpeex here http://users.on.net/~nirving/psp/libspeex-psp.zip and the sample code I have written here http://users.on.net/~nirving/psp/speexClient.zip . Here is a sample encoded file for playback http://users.on.net/~nirving/psp/test-encode.spx

I would be grateful for any feedback, suggestions ideas etc.

Thanks
Back to top
View user's profile Send private message
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Wed Sep 20, 2006 11:19 pm    Post subject: Reply with quote

Doesn't speex work on 320 samples per frame? Perhaps that's your problem?
Back to top
View user's profile Send private message Visit poster's website
nirving



Joined: 20 Sep 2006
Posts: 12

PostPosted: Thu Sep 21, 2006 6:15 am    Post subject: Reply with quote

I am not sure, the example I have created seems to be 320 samples per frame. Does this mean I have to use use each sample 4 times to get anything out?
Back to top
View user's profile Send private message
nirving



Joined: 20 Sep 2006
Posts: 12

PostPosted: Sun Sep 24, 2006 8:14 am    Post subject: Reply with quote

Okay I have made some progress, and managed to get some code to output the sample. Currently I am having to output each bit I have 3 times to get anything of value, by this I mean it was too fast before, so am trying to find out how to convert (interpolate) the 8bit mono @ 8000 to 16 bit stereo @ 44100. People are mentioning some code to do this but I am not sure where to look, any idea?
Back to top
View user's profile Send private message
dsn



Joined: 09 Nov 2005
Posts: 47
Location: Indianapolis, Indiana, USA

PostPosted: Sun Sep 24, 2006 11:56 am    Post subject: Reply with quote

You can convert from 8000 Hz to 44100 Hz with something like this:

Code:

u8 srcSamples[320];
u32 dstSamples[1764];
u32 srcIndex = 0;      // fixed-point -- divide by 10000000 to get integer portion
u32 dstIndex;

for (dstIndex = 0; dstIndex < 1764; dstIndex++)
{
   dstSamples[dstIndex] = scale_sample(srcSamples[srcIndex / 10000000]);
   srcIndex += 1814059;
}


I used this technique in Ruckus to shift pitch, which is the same operation as adjusting the sample rate. This doesn't do any interpolation or other fanciness, but that wouldn't be hard to add. Note that you still have to figure out how to write scale_sample, which I've left as an exercise because I'm lazy. :-) This code assumes that scale_sample will take an 8-bit mono sample and scale it to 16-bit stereo.
Back to top
View user's profile Send private message Send e-mail
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