Getting live data from the iPhone on the Mac - iphone

I'm experimenting with the sensors of the iPhone. At the moment I visualize the data of the accelerometer by logging it to a file, downloading the file via Xcode and loading the file into my Ruby-Processing app. As I'm playing around a lot this process is getting annoying. It would be cool to have a live stream of the data on the Mac and see what happens in real time.
So what would be the easiest / fastest way to build a prototype for playing around with the data in real time?
I imagine, I could just send the data over the network and have a Cocoa / OpenGL app read an visualize it. What do you think? Could you give me some clues on how to do that? Thanks!

Take a look at NSNetServices and bonjour. There's some good examples and using bonjour greatly simplifies the discovery and communication process. The hardest part is the socket fu you use to set up your "server," but the examples provide you with all the code you need.

Related

Stream screen from Mac to iPhone

I want to create a program that stream the screen of my Mac to my iPhone. Kind of like it is done in Liveview. I'm still relatively new to Objective-C, so I don't know where to start to make such an application.
It seems you have to have something installed both on your Mac and on your iPhone, but how would you actually stream the screen of your Mac to your iPhone?
Hope someone can point me in the right direction.
Update of question
Thanks for the answers. Still seems a bit vague to me and I'm not sure I really need full video streaming. Implementing also seems to be a pain, since there aren't any real good resources for it.
Taking a screenshot every second or so and streaming it to my iPhone as an image, would actually be ok. I've figured out how to stream an image with Bonjour from my Mac to my iPhone.
The screenshot I need to send to my iPhone is of the design that I'm currently working on in photoshop. I've figured out how to take a screenshot and how to get a list of all open windows. But how to make a snapshot of an open PSD-file, I don't know.
Any suggestions on that?
It's a very big subject, so not really something that can be tackled with a simple response. However, I would suggest that one approach would be to write a VNC client for the iPhone. Indeed, this open source exists that's probably worth a look:
http://code.google.com/p/vnsea/
Tim
I would go with the frequent screenshot approach. You would prepare a screenshot of the item you want to transmit and then use some easy library like my DTBonjour to transmit these objects via WiFi to iOS clients.
https://www.cocoanetics.com/2012/11/and-bonjour-to-you-too/
If you were using layer-backing then you could also use the renderLayer... methods which would also include sub-layers.
The most fidelity you'd get from encoding the individual screen shots in a streaming video format, though this is way more work.
This is called RFB (or RDP), and most remote-screen applications use RFB/RDP protocol and libraries which implement it.

How to scratch audio like a DJ?

I have to develop an iPhone app which is a DJ app. It includes everything right from playing song to scratching the audio.
Is there a way I can scratch the audio? Are there any good frameworks which you can suggest? Which are best possible options?
I have referred to this links below but didn't help my cause
http://blog.glowinteractive.com/2011/01/vinyl-scratch-emulation-on-iphone/
Scratching Audio
I'd start with reading Kjetil Falkenberg Hansen's recent PhD thesis: The Acoustics and Performance of DJ Scratching to get to grips with the nature of the problem. This should provide you with some effective parameters for your program.
I imagine you'll want to buffer a certain amount of the audio to be 'scratched' and simply advance through said buffer at varying speeds both forward and backwards.
Consider this link (and similar ones) for how to build a buffer.
If the iphone API doesn't provide a useful way to advance through the buffer at different speeds you might consider making your own temporary buffer, then using this to populate the buffer used by the iPhone based on some interpolating function.
BTW - the first link you posted looks very useful indeed! What's it missing?

Turning an iPhone or iPod into a wireless webcam

I'd like to stream video from the camera on an iOS device to a receiver via wifi, in effect turning the device into a wireless webcam. Is there a way to build a small app that captures video input on an iOS app and sends it via an RTSP stream or similar?
As this is an ad hoc experiment, I'm not concerned about App Store guidelines and can jailbreak if necessary.
If I interpret your question correctly you more or less need to solve four problems:
Get the camera feed.
Convert/encode this to the right format.
Stream the data.
Prevent the phone from locking itself and going into deep sleep.
The first one is fairly simple and Apple has as always provided good documentation and examples -> API link. Make sure you check out their example in the end as you will get a CMSampleBufferRef data object back.
For the second and third part, you should check out the CFNetwork framework and specially CFFTPStream for streaming using FTP.
If your are only building this for yourself then you can always turn off the Auto-Lock feature in the settings. If you on the other hand would like to distribute this to other users you could use a trick to play a mute sound every 10 seconds. This is more or less how all the alarm clocks work in the App Store. Here's a tutorial. =)
I hope I helped a little bit at least.
Good luck and best regards!
I'm 70% of the way to doing the same thing. Here's how I did it:
Capture content from video input
Chop video into files for use in HTML Live Streaming.
Spin up a web server on the iPhone and make the video files available.
Connect to the IP address of the phone and viola! you've got live streaming video.
Last time I touched the code I was trying to debug my Live Streaming not working. I'll try and get my source code posted on github this weekend, if you'd like to take a look.

iPhone: HTTP live streaming without any server side processing

I want to be able to (live) stream the frames/video FROM the iPhone camera to the internet. I've seen in a Thread (streaming video FROM an iPhone) that it's possible using AVCaptureSession's beginConfiguration and commitConfiguration. But I don't know how to start designing this task. There are already a lot of tutorials about how to stream video TO the iPhone, and it is not actually what I am searching for.
Could you guys give me any ideas which could help me further?
That's a tricky one. You should be able to do it, but it won't be easy.
One way that wouldn't be live (not answering your need, but worth mentioning) is to capture from the camera and save it to a video file. see the AV Foundation Guide on how to do that. Once saved you can then use the HTTP Live Streaming segmenter to generate the proper segments. Apple has applications for Mac OSX, but there's an open source version as well that you could adapt for iOS. On top of that, you'd also have to run an http server to serve those segments. Lots of http servers out there you could adapt.
But to do it live, first as you have already found, you need to collect frames from the camera. Once you have those you want to convert them to h.264. For that you want ffmpeg. Basically you shove the images to ffmpeg's AVPicture, making a stream. Then you'd need to manage that stream so that the live streaming segmenter recognized it as a live streaming h.264 device. I'm not sure how to do that, and it sounds like some serious work. Once you've done that, then you need to have an http server, serving that stream.
What might actually be easier would be to use an RTP/RTSP based stream instead. That approach is covered by open source versions of RTP and ffmpeg supports that fully. It's not http live streaming, but it will work well enough.

How Do I do Real Time Sound/Signal Processing On The iPhone?

I may be doing an iPhone-based application doing near-real-time sound-processing (filtering, etc). I was wondering the best way to get started. Would I want to create an audio cue for recording and processing sound, as described here?
Edit:
I should be clear. I am not asking how to do signal processing, in general. I know some of that and my team's expert will handle the rest. I asking what the "low level" interfaces to sound data on the iphone are.
Edit2:
My iphone development has been pushed back a week or two so I don't have access to the deve kit right now. Once I have access to the kit, I'll mark one answer or another correct.
Sound processing is a big subject. AudioQueue will get you the raw data. Apple provides two samples that will get you started using AudioQueue: SpeakHere and AurioTouch.
I used SpeakHere as a starting point for some audio processing I wanted to do. It's relatively easy to understand, and has all the pieces to do input and output.