Sign in to follow this  
WillPash

Alternative to SDL_ConvertAudio for format converting & sampling

Recommended Posts

Hi There

I am writing a audio program (using C++ and OpenAL), and I want to convert my PCM and format data on the fly (Goung from 44000 to 22000, or two channels to one, 16 bit to 8 bit, etc). Either upsampling or downsampling the audio. I like the function SDL_ConvertAudio, but I don't use SDL. Does anyboy know if there are algorighms, papers or libraries available for me to look at and give me an idea on how to approach this. Has anybdy had any experience with using PortAudio library.

Regards

Share this post


Link to post
Share on other sites
You have three separate issues there: resampling, downmixing and sample type conversion, respectively.

For the former, I have separated the resampler code from Speex to create a lightweight BSD resampling library, and I added a bunch of bug fixes and robustness enhancements. If you're interested, I can upload a copy of my working repo somewhere. You can always link with Speex and get the resampler for free but I thought that would be overkill.

For downmixing some algorithms exist, and if you only need stereo to mono that should be real simple, a google search should take you there in no time.

Sample type conversion is trivial. 8 bit is unsigned with 0 being 128, 16 bit is signed between -32768 to 32767. Off of the top of my head, int16 Sample = (float(OriginalSample) - 128.0f) / 128.0f * 32767.0f for 8 to 16 bit, and reverse for the other direction.

Share this post


Link to post
Share on other sites
That sounds great Starfox. With the bugfixes with libspeex, point out the fixed bugs to speex.org as your contribution will be an overall help for the whole community. I'm looking on downmixing after your suggestion. I can get your suggestion on Sample type converting, but I will have to do more researching on what I have to d. On libspeex, which source files did you specifically work on.

Share this post


Link to post
Share on other sites
Quote:
Original post by WillPash
That sounds great Starfox. With the bugfixes with libspeex, point out the fixed bugs to speex.org as your contribution will be an overall help for the whole community. I'm looking on downmixing after your suggestion. I can get your suggestion on Sample type converting, but I will have to do more researching on what I have to d. On libspeex, which source files did you specifically work on.


I submitted my patches to the Speex project and they have been accepted ( search for Sherief Farouk in the mailing list) - my resampler code is separate because I found out that there is no commercially viable resampling library available, and linking with the entirety of Speex for just the resampler is overkill. I'll upload my whole repo to bitbucket as soon as finals week is over.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this