Different Volume settings for Different players - iphone

I am implementing a audio based application. In my application I need to play the songs from my internal iPod application and application sounds simultaniously. I used 2 players , one with avaudio and another one with MPMusicPlayer. But my problem is I need to input 2 different volume levels for these 2 different players. When I try to do it it is changing both players volume.
Can you guys please help me on this?
Thank you,
Sekhar.

Related

How can I record the internal audio of my musical app? (NOT from microphone!)

I've published a MIDI-based app that generates sounds. I'd like to implement a REC button, to record and save/share the user's musical creations. I can't manage to find a solution to do that. I've found a lot of tutorials about how to record sounds from microphone or other external sources, but I care about the internal audio.
I'm using AVFoundation with an AVAudioEngine to which I've attached and connected a bunch of AVAudioUnitSampler with a DLS Soundbank loaded.
The app works great and it's already downloadable on the store, but recording is an important missing feature. Any help would be really appreciated. Thank you.
Recently I have worked on an app that allow the user to export the sound and use it out of app. If the user can create sound freely, you should have an internal representation of that sound, that can be manipulated in memory. And the UI just presents that internal representation to the user.
It's the same case when you have an array of animals, for example, and present that array as a table view to the user.
There's another problem, if you record the sound, the sound must be played completely to be exported. Is it really necessary? Just rendering a 2 ~ 3 minutes sounds in 2 ~ 4 seconds sounds more reasonable.
So, you really must record the sound or it's just missing some in memory representation of it?
I think this is what Soundflower does. After installing it, in your app you set Soundflower(2) or Soundflower(64) as your output device (in the device list you'll also find Headphones and USB-out), then in your recording app you select Soundflower(2) or (64) as your input. I think my version of soundflower was installed by a Korg app. The (2) and (64) are the number of channels. (2) for stereo, and (64) for any number of channels out, up to 64 channels.

24 layers in unity3d for developing multiple mini games is not enough

My Team has a project to develop multiple mini games on different scenes in one project. I found that it will take 4 to 7 layers to work on one game, and the empty layer will soon be running out since we are developing many games.
We are thinking to write a script to manually control the collision by Physics.IgnoreCollision function. The question is that will this approach be efficient and necessary? Is there any proper way to solve this problem?
Thank you!

How to play two audio files from the iPod library simultaneously?

I know that the MediaPickerConroller can be used to access the iPod library, however I'm not sure that it can play two songs at the same time. AVFoundation would allow this, but then how do you get AVFoundation to access the library? Is there an easier way of doing this? Any help appreciated, thanks.
One way - though not exactly an easy way - to play more than one audio files at the same time is to use an Audio Processing Graph. "MixerHost", the example app by Apple, is a good starting point. "AudioGraph" (https://github.com/tkzic/audiograph) has more functionality than you want, but the manual is helpful to understand the basics of audio processing graphs.
The MediaPickerConroller will allow you to select more than one item from the iTunes library. You will have to get the list of URLs from the media picker and connect them to the graph yourself.

Outputting sound using multiple audio routes at the same time in an iPhone App?

I'm playing around with audio routes in AVAudioSession at the moment and I'm wondering whether it is possible to output sound to multiple audio routes at the same time i.e. a sound playing from the speaker and a different sound playing in the headphones? Ideally I'd like to be able to play separate sounds via a dock connector (using a 3.5mm jack adapter) and the headphone jack at the same time so if someone could tell me whether or not this is actually possible that would be a great help.
Thanks
I don't think it was possible three years ago when you wrote this, but it is possible now to play one sound through the headphone jack and another through a USB audio interface connected to the dock connector. This WWDC presentation walks you through it and provides sample code.
I don't think it's possible to play separate sounds through the headphone jack and the speaker because the AVAudioSessionRouteDescription only shows one of these built-in output ports at a time. You'd have to add a second audio interface via USB, which adds a second output port to the AVAudioSessionRouteDescription. I'm testing with a Roland Duo-Capture mk2 right now and it's working.

play two sounds simultaneously iphone sdk

I am trying to make a small music app on the iphone. I want to have an octave a piano which will respond to touches and play the key or keys that the user touches. How would i be able to get two or more sounds to play at the same time so it sounds like a chord? I tried using AVFoundation but the two sounds just play one after the other.
You would have to use AudioQueueServices. The docs are here:
Apple.com - AudioQueueServices Reference
Essentially you would have to write some code to open up multiple outputs, and then prime the queue and have them block before AudioQueueStart(AudioQueueRef aq) until everything was primed and ready and then let them go.
AVAudioPlayer isn't really good enough for this sort of thing, unfortunately.
If you create multiple AVAudioPlayers you can play them at the same time, and they will mix per the restrictions outlined in the documentation (not all file types can be played simultaneously).
If you allocate them first, then play them in order, they will play at virtually the same time.
If you need absolutely perfect timing, use the AudioQueue as described above or use OpenAL.