*Update*
I neglected to point out that you should un comment #define _USE_SSE in the config.h as mentioned below. This preproc directive will allow you to run on device. It was also mentioned that you could get more speed out of Speex if you #define FIXED_POINT instead of FLOATING_POINT. I have not verified this and Speex runs acceptable in my implementation without it but its worth mentioning.
*Update*
I get a lot of questions on how I implemented Speex on iPhone. So I’m going to take this time to do a quick tutorial series. This is part 1, which will show you how to import the speex source into XCode and get a clean compile.
First download and explode the Speex source to any location. Run “./configure” in the exploded folder and create an iPhone subfolder within the speex in this same location. Now we’ll begin creating an XCode project inside the iPhone subfolder. I use a static lib project so that I can reused my work in several other projects, but if you’re new to XCode and iPhone you may forego static libs and just create a typical view based project. I start out being anal about my project structure. I prefer to have only the project folder and a single src folder at my project root. I realize this is non standard iPhone but it makes perfect sense from a build perspective. (I see: build description + src = build output) So a little refactoring and adjusting my target settings to find the new location of the plist and pch files.
- Drag/drop the libspeex and include/speex folders into your XCode project.
- Drag/drop the config.h file from the unpackaged speex tar into your project.
- Add the include folder to your header search path
- Double click the project in the left hand tree and add the following user defined setting: GCC_PREPROCESSOR_DEFINITIONS = HAVE_CONFIG_H
- (User defined settings can be added by clicking the little wrench in the lower left corner.)
- Finally, you need to take “libspeex/echo_diagnostic.m” out of the compile loop. Either uncheck the target membership box next to the left hand “Groups & Files” tree pane on the left or open and drill into your Application (or static lib) target and select the “Compile Sources” branch. Find the file under there and delete it.
By now your compiles should be squeaky clean. Stay tuned to the next parts of the series where I’ll discuss how to import ogg and wave container formats into XCode and perform Speex decompression in an app. I’ve upoaded my source (SpeexLib) to my box.net account so you can click here to download it or find it in the Box widget to the right of this post.

Thank you sooooooooooo much!!!!!!!!!! Great tutorial!!!
By: Harris on December 4, 2010
at 6:33 pm
Check out part II. It took a while but Im now ready to start running with part 3. Eventually we’ll have Core Audio integration and then move onto encoding.
By: Cliff on December 8, 2010
at 10:37 pm
[...] part I of this series I explained how to get Speex to compile. Today we’ll try to import the OGG [...]
By: Speex On iPhone Explained Part II « Can’t see nothing but the source code on December 7, 2010
at 9:27 pm
The method mentioned here let you build libspeex for mac or iphone simulator only, not for real iphone/ipad. In order to make it working or real device (or even compile for target device on mac) you’ll need to edit config.h and comment out #define _USE_SSE. You can also comment out #define FLATING_POINT and uncomment #define FIXED_POINT – can be a bit faster.
By: Docent on December 14, 2010
at 9:49 am
Docent,
These are all good points and a clear oversight on my part. In an effort to recreate a demo voice application I forgot to run a smoke test on the device. I was in a rush to throw this tutorial together as I had been getting feedback from a few on exactly how all of this comes together. I will update my post accordingly.
By: Cliff on December 14, 2010
at 8:15 pm
Hi, Cliff, Thanks for your tutorial. I succeeded to compile the speed library following your tutorial, but should I always create the project inside the speex folder?
By: Xiqi Liu on September 14, 2011
at 9:10 pm
No you can situate the files anywhere on your hard drive so long as you give the proper relative paths to the includables.
By: Cliff on September 14, 2011
at 9:38 pm
Thank you. I shall try it. For now, I kinda meet a more serious problem. I don’t have to pass AudioQueen buffer to the speex_preprocess_run function.
By: Xiqi Liu on September 15, 2011
at 12:45 am
“I don’t have to pass AudioQueen buffer to the speex_preprocess_run function.” –> I don’t know how to pass AudioQueen buffer to the speex_preprocess_run function.
By: Xiqi Liu on September 15, 2011
at 12:46 am