| View previous topic :: View next topic |
| Author |
Message |
nirving
Joined: 20 Sep 2006 Posts: 12
|
Posted: Wed Sep 20, 2006 6:41 am Post subject: libSpeex and playback |
|
|
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 |
|
 |
ooPo Site Admin
Joined: 17 Jan 2004 Posts: 2032 Location: Canada
|
Posted: Wed Sep 20, 2006 11:19 pm Post subject: |
|
|
| Doesn't speex work on 320 samples per frame? Perhaps that's your problem? |
|
| Back to top |
|
 |
nirving
Joined: 20 Sep 2006 Posts: 12
|
Posted: Thu Sep 21, 2006 6:15 am Post subject: |
|
|
| 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 |
|
 |
nirving
Joined: 20 Sep 2006 Posts: 12
|
Posted: Sun Sep 24, 2006 8:14 am Post subject: |
|
|
| 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 |
|
 |
dsn

Joined: 09 Nov 2005 Posts: 47 Location: Indianapolis, Indiana, USA
|
Posted: Sun Sep 24, 2006 11:56 am Post subject: |
|
|
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 |
|
 |
|