iPhone audio equalizer - iphone

I am playing video from the web with AVPlayerLayer :
AVAsset *newAsset = [[AVURLAsset alloc]initWithURL:url options:nil];
AVPlayerItem *newPlayerItem = [[AVPlayerItem alloc]initWithAsset:newAsset];
audioPlayer = [[AVPlayer alloc]initWithPlayerItem:newPlayerItem];
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:audioPlayer];
And i want to be able to add Audio Equalizer to the video. Something like :
Pop, Flat, Balled, Blues, Classical, Dance, Metal
I search for and documentation for this in Google and in apple developer program resources and didn't find nothing.
And i also noticed that some apps have this function, but it's for iOS 6.1 only.
Any help with this issue? Did apple have something build-in or it's a non-apple source?

This Stack Overflow question has answers offering several different solutions: How to make a simple EQ AudioUnit (bass, mid, treble) with iOS?

Related

change sound pitch (not in realtime)

i alway had this question in my mind, but wherever i asked, i could never get an answer or a suggestion that would be helpful:
How can i pitch a sound (not realtime) ?
Im using AVFoundation framework to play my sounds like so:
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:TempRecFile error:nil];
player.volume = 1;
[player play];
How can i set the pitch or the frequency of my sound without having to use some othere frameworks like OpenAL. Although, if you know a place where i could learn some OpenAl you're very welcome :D
There are a few iPhone time-pitch shifting libraries mentioned the this StackOverflow answer: Real-time Pitch Shifting on the iPhone,
which work offline as well as potentially in real-time.
Here's a wikipedia article on time-pitch technology, and a dspdimention overview on the topic.

playing a sound doesn't work on iPhone

I've added a sound to my app.
In my .h i've added:
CFURLRef soundFileURL;
SystemSoundID soundFile;
in my viewDidLoad in my .m:
soundFileURL = CFBundleCopyResourceURL(
CFBundleGetMainBundle(),
CFSTR("sound"),
CFSTR("mp3"),
NULL);
AudioServicesCreateSystemSoundID(
soundFileURL,
&soundFile);
and lastly i've added a -playSound method:
-(void)playSound {
NSLog(#"playSound");
AudioServicesPlayAlertSound(soundFile); }
It works fine on the iPhone Simulator, but when I build the app on my iPhone the console says the sound was played but it wasn't.
I read that many others had this problem too but I didn't find any solutions.
What's wrong?
It could be your encoding - the audio codecs on the simulator are much different than those provided by your actual iPhone hardware. Try reencoding.
Also - you don't want to use an mp3 for a sound, you want to use a non-compressed file format (I suggest aiff from experience) because there isn't dedicated decoding hardware to support the sound decoding you're trying to do. (There is for playing music, which mp3 is recommended for)
I would recommend AVAudioPlayer in the AVFoundation framework. It has a simple asynchronous interface for sound playback on iOS.
Check out the Apple programming guide here.
I had a similar issue. It turned out I was referencing "Horn.caf" with
NSURL *hornSound = [[NSBundle mainBundle] URLForResource: #"horn"
withExtension: #"caf"];
Note the difference in case; My OS X Lion install is on a case insensitive file system.
Changing the code to the following fixed the issue.
NSURL *hornSound = [[NSBundle mainBundle] URLForResource: #"Horn"
withExtension: #"caf"];
Hope that helps others.

How do you implement seeking using the AudioStreamer sample application as a base?

I need to play some audio streaming contents on iPhone, but there are some options and problems I can't solve:
1. http://cocoawithlove.com/2009/06/revisiting-old-post-streaming-and.html
It is a library provided by Matt Gallagher, but I saw the Limited scope, and I would play
a single song, not a radio station.
2. Suggestion from zonble
NSURL *URL = [NSURL URLWithString:#"http://zonble.net/MIDI/orz.mp3"];
NSData *data = [NSData dataWithContentsOfURL:URL];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:data error:nil];
But I need streaming for each "single song".
3. Using MPMoviePlayerController to wrapper.
Since the Class update new method, and
#interface MyAudioStreamer : UIViewController {
MPMoviePlayerController *mp ;
}
instead of [self addSubview:mp.view] I use my own xib file to implement play and
stop methods, but in this case, I have no idea to implement seekForward or seekBackward.
Is there any good idea to do AudioStreamer?
==== Update ====
after google 'AVPlayer' ,i used 3. Using MPMoviePlayerController to wrapper. to implement a auidoStreamer-like player ,there is something to share :
1.'playbackDidFinished' state
there're 2 conditions : a song did finished and play next song or a song interrupt by user press stop or exception, i used enum to filter my state.
2 multi-task playing your song in background
reference from https:// devforums.apple.com/message/264397
and if iOS SDK update, the solution might be changed because method would be diplicated. so i suggest to read library provided by Matt Gallagher.
anyone who konws when the library have no codec match download item (for example, my item encode by .AAC 128-bit and the library not support or at most .AAC 64-bit), what happen would the player be ?
You can either parse the icy meta data yourself, or if you're using iOS 4.0 you can playback using an AVPlayer and observe the timed metadata to discover the song boundaries and titles.

Playing Sound Effects while in Background Mode

I have a need to play some sporadic sound effects in the background of an iPhone app. From everything I've read and experienced with iOS 4, I can keep my app running in the background as long as I am running GPS by specifying "location" as a background mode. That actually works. But at times I want to play a sound effect...in other words, it's not "continuous" sound which I see reference to.
But the app is running, so why can't I just use AVAudioPlayer to play some sound effects? Would another sound API work?
GAHHH!
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:#"BEEP" ofType:#"aiff"];
NSURL *fileURL = [[[NSURL alloc] initFileURLWithPath: soundFilePath] autorelease];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
player.volume = 1.0;
[player prepareToPlay];
// play
[player play];
I think it is important to clarify that your application is not running in the background. Rather, your application is 'put to sleep'. The info.plist background process value that you specify tells the OS that it should wake your application and allow it to respond to specific types of events. From the Apple Documentation
Each of the preceding values [audio, location, voip] lets the system know that your application should be woken up at appropriate times to respond to relevant events.
In your case, your application is frozen and is only able to respond to the type of event that you specify (location, or GPS).
You don't make it clear what context this code is in, so at this point it's difficult to tell you why the audio is not playing. Also, you need to make sure that your application is running in the background for the specified purpose. If you are using the location mechanism and not using GPS in your app, you may get rejected when you submit your application.
You may also want to refer to the Checklist for Supporting Multitasking to ensure the structure of your application implements their requirements.
[EDIT]
You have a good example of background playback while monitoring GPS position here :
http://www.informit.com/articles/article.aspx?p=1646438&seqNum=5
And it's using AudioToolbox rather than AVAudioPlayer
I've managed to do it using the AVAudioPlayer.
did you also add the audio value in the info.plist for key UIBackgroundModes ?
The answer is that it won't work with AVAudioPlayer. Use the AudioServicesPlaySystemSound API instead.

Pre-built audio player UI on iphone?

My boss seems to think there's a way to play audio files via a built-in QT interface that comes up with a modal UI, much like address book framework does.
Also, the mail app pops up a QT modal player to play attached audio files and then hides itself when done.
I've done a good 2 hours of research and I cannot find any pre-built UI for playing audio. I understand that I can do it via AVAudioPlayer, but that still requires I build a custom UI, which is fine, but we're looking for visual familiarity and consistency.
I just now found MPMusicPlayerController, but it appears to only play itunes media, not media from file paths.
So, is there a pre-built audio player UI?
MPMoviePlayerController can also be used to play audio files (although it's not recommended):
MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:#"http://www.freeaudioclips.com/music1/Sound_Effects/austinmail.wav"]];
// Show Audio player just to test it out
if (mPlayer)
{
[mPlayer play];
}
Read Apple's Documentation and for more details.