Anyone knows how to audio sampling rate conversion?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
fishdrop
Posts: 16
Joined: Tue Oct 31, 2006 8:46 pm

Anyone knows how to audio sampling rate conversion?

Post by fishdrop »

I want to develop mp3 player which plays any sampling rate mp3.
But PSP's audio output is fixed at 44.1khz
So, sampling rate convertsion is needed in runtime.
If possible, I want to know how use firmware system call for performace issues.
Anyone knows this?
Tinnus
Posts: 67
Joined: Sat Jul 29, 2006 1:12 am

Post by Tinnus »

You could use SDL to do the audio conversion and playing. Of course SDL might slow things down a bit, although not too much, but as you're doing a player and not something of which the sound is secondary--like a game for example, I don't think a small overhead in sound output is a problem.

Your own solution might even turn out to be slower then SDL's, who knows :) I'd say try SDL and see if the speed fits your needs.
Let's see what the PSP reserves... well, I'd say anything is better than Palm OS.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

The most common sample rates are evenly divisible by 44100 are they not?
So for say 22050, you could just let pspaudio play at 44100, and send the
same data twice, for 11025, send it four times. Then there's no overhead
for those sample rates. Below that, I think is not evenly divisible, but does
anyone want to play music at such low quality?
fishdrop
Posts: 16
Joined: Tue Oct 31, 2006 8:46 pm

Post by fishdrop »

Tinnus wrote:You could use SDL to do the audio conversion and playing. Of course SDL might slow things down a bit, although not too much, but as you're doing a player and not something of which the sound is secondary--like a game for example, I don't think a small overhead in sound output is a problem.

Your own solution might even turn out to be slower then SDL's, who knows :) I'd say try SDL and see if the speed fits your needs.
Thanks. I will try it.
fishdrop
Posts: 16
Joined: Tue Oct 31, 2006 8:46 pm

Post by fishdrop »

Art wrote:The most common sample rates are evenly divisible by 44100 are they not?
So for say 22050, you could just let pspaudio play at 44100, and send the
same data twice, for 11025, send it four times. Then there's no overhead
for those sample rates. Below that, I think is not evenly divisible, but does
anyone want to play music at such low quality?
I want to play 48Khz contents.
User avatar
dsn
Posts: 47
Joined: Wed Nov 09, 2005 11:48 am
Location: Indianapolis, Indiana, USA

Post by dsn »

You can approximate the conversion from 48kHz to 44.1kHz by skipping every 12th sample. This will introduce a small degree of inaccuracy though: a 5-minute track will be about 1.3 seconds shorter than normal, and the pitch will be increased by a vanishingly small (and probably imperceptible) amount.

If you want something more accurate, you can use fixed-point math to keep track of how many more samples you need to play before skipping one. This is how Ruckus adjusts the pitch of an MP3 (which is what you're trying to do--pitch adjustment and sample rate conversion are the same thing). Source here: http://svn.captaindan.org/ruckus/trunk/audio.c

If you want an absolutely insane level of accuracy, you can interpolate samples. But you're on your own with that. :-)
digihoe
Posts: 108
Joined: Sat May 14, 2005 7:40 pm

Post by digihoe »

Well, there should be some way of doing it... Some videos come with 48kHz AAC, but that's AAC, but it means that atleast the hardware can produce 48kHz sound...

@dsn, fanboy alert...
I just wanted to tell that I love Ruckus, great software you have made there!

Best regards!
Post Reply