External controllers for iPhone - iphone

Are there any external buttons/controls that can be plugged into the iPhone that can be used within an app. If so, does anyone have any links to any code to use with these controls.
I was thinking of some kind of iPod controller that I could hack that could be plugged into the slot on the bottom of the phone.
Cheers.

Yes. Several USB MIDI controllers are supported via the Camera Connection kit on stock OS iOS devices. An app can use CoreMIDI in/out messages to get input from the buttons on these external MIDI controllers.
But an app can't use a generic hackable USB input device under the stock OS, unless the developer is the manufacturer and also a member of Apple's MFi program.
ADDED:
...or you hack the USB device so that it imitates one of Apple's supported MIDI devices. Example of doing this with an AVR microcontroller is here.
Apple's CoreMIDI reference is here.
ADDED #2:
If you want even more accuracy for a timer app, consider using the mic audio input jack, and connecting some buttons to audio chirp generators (could be done either with analog circuitry or a tiny cheap micro). Use different chirp frequencies for different buttons. Some suitable DSP code on the iPhone could probably determine the relative timings of audio input chirp signals with sub-millisecond accuracy.

There are many solutions to this, most involve jailbreaking the iphone.
The most famous/popular is the iControlPad.

Related

Data transfer between iphone and BT device

Is it possible to transfer data from/to iphone through headset using some modulation(fsk for example)? From theoretical point of view it looks completely possible.
Yes, you could consider in-code FSK demodulation.
Take a look at O'Reilly's iPhone Hacks - there's a nice chapter on serial modem.
True - it uses Headphone Jack but you'll get the feeling on how to handle audio 'data'.
You can also download the source from iPhone Hacks source code
EDIT: there's also an awesome link collection in not really Jake's answer here:
Using an iPhone audio dongle to transmit data

iPhone Bluetooth Audio API

My car has bluetooth capabilities for connecting to my iphone for phone calls; however, it does NOT support bluetooth audio for music streaming. I know apps like viber or skype also use bluetooth for phone calls. My question is: is it possible to write an app that fakes phone calls to stream music to my car, as if someone is calling me (but is actually playing music)? Is there some other way to hack this to get bluetooth audio streaming?
No need to jailbreak your phone. Just buy the A2DPblocker app. Costs $2.99. Sound quality isn't perfect but better than the alternative. Worked for my 2010 Volkswagen so should work for any other car that supports bluetooth but not streaming music.
First poster -
There is already an app to do this - it's part of SBSettings called Bluetooth Mono that needs to be installed (so only MONO and only for JB'd phones).
Second poster -
I suspect you are correct about HSP - I've installed the app and the sound quality is terrible.
So, I've put all my music on a USB stick and leave it permanently plugged in. Far superior sound.
Mike
I don't think there's an easy way to do this. But the bigger issue is that it would sound terrible. The bluetooth connections for doing phone calls use headset profile (HSP) and are low bitrate, mono, and frequency limited to voice ranges.
Applications for streaming audio/music over bluetooth use A2DP profile, which is much higher bandwidth and stereo.
If you try to pipe music over a an HSP phone link it will sound horrible, just as it does if you are talking to someone on the phone and they have music playing in the background.

Capture audio from dock connector

I'm writing an app which captures audio from the mic input which works fine but I want to capture audio from the dock connector rather than the mic input. I know that pins 5 and 6 are audio inputs, so my question is from a software point of view, is this possible and would I just use the AudioToolbox framework functions as I am now?
No. This is not possible for regular apps on stock OS iOS devices. Inputs on the dock connector appear to be inaccessible from any app except when working under Apple's MFi program. You have to contact Apple for any information on enrolling in this program, which may involve some paperwork.
Apples Camera Connection Kit might allow using USB microphones for input. There are also some 3rd-party audio dock input products.

iOS framework to get audio in from dock connector

How would I go abouts playing an 'audio in' through the dock connector in an iOS app? I'm making an app just for myself and have no plans of putting it into the apple store. I have the 30pin breakout board, and on it there are pins for L/R audio in, but I can not find any info on how to use them?
Thanks
As far as I'm aware, your only officially supported option for any accessory using the dock connector would be to use the External Accessory Framework, which requires enrollment in the Made for iPod Program (overkill for your purposes). However, the iPhone and iPod both support line-in via the headphone jack, and there are plenty of apps that make use of audio input. At least it provides some possibilities.
Have you looked at the pinouts for the dock connector floating about? It appears that certain resistances connected to pin 21 indicate to the iDevice what is connected.
68kΩ seems to be the magic number for audio in/out.

Sharing Audio over bluetooth

I want to write a function in my iPad App, which allows me to stream the music choosen on iPad to the connected Game-Interfaces (iPod, iPhone...) via bluetooth. Does anyone knows a simple solution or maybe wants to share some sample code?
Thanks for help!
I am doing something very similar. I have my iphone connecting to multiple devices to stream audio to them, but I want the device that is streaming the audio to also play audio as well.
You can look into the GKSession in the GameKit API and that should give you a good start.
Also maybe openAl, but I think that might be a little overboard. I heard Core Audio has a built in feature for bluetooth devices that are connected to play audio through them but I dont think this goes for iPhone, iPad, iTouch etc....
I have also created my own peer connection interface that allows me to see multiple bluetooth devices that are running my app. I then can click each one and each gets connected. I then I added a test to push a text message to all connected devices for testing. Next I need to find out how to stream audio to the connected apple devices.
If anyone has any info on this I am sure we would both appreciate it.