iPhone short file to play - iphone

I am wondering if it is possible to play several little audio files on iPhone. I created a sound file of 25µs but I can't play it on Simulator or on the Device.
So I created several files 25µs, 50µs and 100µs but even if I use NSArray or NSMutableArray with ÀVQueuePlayer`I couldn't play it!
Do someone know the minimum time to play a sound or if what I am doing is possible?
Thank you for your answers
PS : My project is to communicate with other device on the audio

What makes you think it is not being played ? 25µs is 25 millionth of a second long !
I suggest you start playing a clip which is audible, then cut its length in half
and repeat until it becomes inaudible. Is your intention to have the other device listen ? you could get your play/listen loop working with audible clips then drill down.

Related

Playing a real time video stream from iPhone camera on a 20 second delay

I am trying to see if it is possible to record a video from the iPhone's camera and write this to a file. I then want the video to start playing on the screen a set time after. This all needs to happen continuously. For example, I want the video on the screen to always be 20 seconds behind what the camera is recording.
Some background:
I have a friend who is a coach and would like for his players to be able to see their last play. This could be accomplished by a feed going to a TV from an iPad always 20 seconds behind what is recorded. This needs to continually run until practice is over. (I would connect the iPad to the TV either with a cable or AirPlay to an Apple TV). The video would never need to be saved and should just be discarded after playing.
Is this even possible with the APIs AVFoundation offers? Will the iPhone let you write to a file and read from a file at the same time to accomplish this? Any other better way to accomplish this?
Thanks for your time.
Instead of writing to a file, how about saving your frames in a circular buffer big enough to hold X seconds of video?
The way I would start to do this would be to look at what's provided in AVCaptureVideoDataOutput and its delegate methods (where you can get the frame data from).

How to play sound on "Ringer & Alert Volume" level

In my app I want to have an alarm/notification on "Ringer & Alert Volume" level.
In other words on the volume level which phone rings or alarms are used on (Preferences/Sound/Ringer and Alerts). It is different from the system volume level which changes with the volume buttons.
It should also play more than 30 sec.
I know it's possible because some clock apps can do that.
UPDATE:
OK I found an unideal solution. If use AudioServicesCreateSystemSoundID and load my own sound file (aif, wav, etc no mp3 or other compressed audio) than it works.
The only problem is that it has to be 30 sec or shorter, but I can can cut it into 30sec pieces and play them piece by piece.
It does not work when on silent switch on which is a problem for me.
Code:
SystemSoundID mySound;
AudioServicesCreateSystemSoundID(CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("mySound"), CFSTR("aif"), NULL), &mySound);
AudioServicesPlaySystemSound(mySound);
I suspect that OpenAL should do that. Does anyone has a simple example which loads a aif/wav file and plays it on iPhone. I found some complicated examples, but all I need is just play and stop a sound (even if it's leaking that's fine).
I found it out myself. I have to use AudioServicesCreateSystemSoundID and load my own sound file (aif, wav, etc no mp3 or other compressed audio)
The only problem is that it has to be 30 sec or shorter, but I can can cut it into 30sec pieces and play them piece by piece.
It does not work when on silent switch on
Code:
SystemSoundID mySound;
AudioServicesCreateSystemSoundID(CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("mySound"), CFSTR("aif"), NULL), &mySound);
AudioServicesPlaySystemSound(mySound);
You should look into AVAudioPlayer class. It will allow you to play sound files of any duration and you can control the volume output for the specified files you wish to play. I'm not in front of my mac otherwise I would provide code. Let me know if you need further instruction.

Play mp3 file smoothly upon dragging a scroll using AVToolbox or openAL

I have been facing this since so many days but I have not reach to any conclusion.
My problem is : I want to play an mp3 file but not simply by clicking on a play button.
It is this way I want to play it.
*There is a slider that I can drag using finger, I want that the mp3 should play with the frequency with which I am dragging the finger (or speed with which I am dragging my finger, so that it will give an effect of fast forwarding (funny type of voice)) or if I drag slider slowyly the output will be slow *
The problem is the output of the sound is not coming out smooth. its very distorted and disturbed voice.
I want the outuput to be smoother.
Please help. Any suggestions please. Presently I am using AVAudioPlayer and passing the time value based upon slider input to play the file. (It does not seems to be feasible though).
I feel that it is possible using openAL only and no other way. Because using openAL we can modify the frequency of the sound file (pitch)
CAN SOME ONE PLEASE REFER ME A LINK TO openAL implementation for iPhone . I have never played a sound file using openAL
Help!!
You won't be able to do it with AVAudioPlayer, as it does not support pitch operations.
You can load and decode the entire track into memory for playback with OpenAL (which supports pitch), or you can do realtime loading/decoding and pitch changing using Audio Units (MUCH lower level, and more complicated, though).

Playing portion of an audio file on iPhone

Does anyone knows how to play a portion of a sound file on the iPhone?
Using the SDK, or any other library (Cocos Desnhion...).
I know how to play an entire sound, but not an exact portion of it (eg. from 2,5ms to 6ms).
Thanks!
Vincent
AVAudioPlayer has a currentTime property. Set it to start playing the file at a specific time mark and then watch its progress to stop playing when it reaches a desired mark.

How can Play Audio file in loop without any interruption?

I am trying to develop a simple iPhone app. I need to play sound within a loop.
How can Play Audio file in loop without any interruption ?
Take a look at the new AVAudioPlayer class in the 2.2 release:
http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html
It has functionality for looping sounds.
I really don't know the iPhone SDK at all, but this should be quick: try making the sound itself looping. That way, you should be able to play it with just a single call, and won't need to worry about timing the repeat properly to restart it at the exact right moment.
For instance, WAV files have very flexible support for looping, and any decent audio editor should let you set looping points.
The AVAudioPlayer has numberOfLoops property where you can specify the number of times you want the audio to loop.