iphone audio speed control programmatically [duplicate] - iphone

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
AVAudioPlayer: How to Change the Playback Speed of Audio?
I want to control the speed of the audio played by AVAudioPlayer, So is it possible to control the speed of the audio from slider controller?

I got solution with the help of OpenAL only. With the help of SimpleAudioEngine n CDAudioManager I have done it. referance link : http://www.learn-cocos2d.com/api-ref/1.0/CocosDenshion/html/interface_simple_audio_engine.html

Related

Swift: how to set the iphone volume programmatically [duplicate]

This question already has answers here:
How to change device Volume on iOS - not music volume
(9 answers)
How to change an iOS device volume programmatically?
(4 answers)
Closed 6 years ago.
I am trying to create an alarm app and I have noticed that apps like Sleep Cycle will set your volume to max right before the alarm goes off, even if you had the volume at very low.
I have tried using AVAudioPlayer and all I have seen with MPVolumeView is that the user must do it.
Is there any way I can turn it up without the user having to do it?
Thank you for your help.
If I could please get the code in swift
You just need to import MediaPlayer. You can do as follow:
import MediaPlayer
And to set the volume to maximum
(MPVolumeView().subviews.filter{NSStringFromClass($0.classForCoder) == "MPVolumeSlider"}.first as? UISlider)?.setValue(1, animated: false)

AVAudioPlayer or MPMusicPlayerController for playing simentanously & in background

I have the following needs to audio: it needs to be able to play at least 2 local audio files and it need to support playing in the background, so the user can close the app and multitask while the audio still plays. What of the 2 options are the best bet?
AVAudioPlayer is your best bet. As mentioned in the comment "AFAIK MPMusicPlayerController is used for local files inside the iPod Library."
Having said that, can you please give more details about your problem?

iPhone short file to play

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.

How to play two mp3 audio? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
2 mp3 sounds at the same time in iphone?
Hi i am creating test application where i am using two mp3 audio file.One for the background music and second file play when user clicked the button.I am using AVAudioPlayer for both and the background music is playing in appDelegate class but i am handling it from the ViewController class.Please if anybody know about this problem please help me out.
You cannot play two compressed formats simultaneously. Try converting one of the files to AIFF, CAF or some other uncompressed format.

IPhone mp3 playback problem [duplicate]

This question already has answers here:
AVAudioPlayer - Drop in Framerate
(2 answers)
Closed 4 years ago.
I'm writing a game for iphone, and without background music it runs smoothly at 30 fps. But if I add music (using AudioQueues or AVAudioPlayer, both give similar effect), framerate periodically drops to 10 (about once per second), and then returns to 30. Music is mp3#128kps, 44kHz. It degrades performance not constantly, but at certain moments in time, which causes very jerky gameplay. Did anyone meet such problem? Is there any way to make cpu load for mp3 decoding/playing back more uniform? I'd rather have constanly 29 fps than 30 fps most of the time, and 10 once per second.
Maybe you could increase the priority of your rendering thread? Or take it into a different Run Loop (if that is how you're doing animation).
Couple of thoughts:
1) It might be work trying converting your files into another format and see if you still have this issue. I have had great success with using CAF files, just run afconvert over them.
afconvert -f caff -d ima4 <your mp3 file>
2) Also, is there any connection between the slowdown and track changes? I have often seen similar things when changing tracks (or restarting tracks). I think it has to do with the load it takes to read the file from 'disk'.
This is most probably caused by using the AmbientSound audio session category, see this question. You can easily solve the problem by switching to the SoloAmbientSound category.
You need to profile your app.
I'm getting 60fps regardless of bitrate.
It would be best if you showed us your code. Have you checked into the audio buffer options, it might not be optimal for what you need. Are you comfortable with audio Units?