Random channel audio playback

(OSX / Cocoa)

I need to be able to take any sounds (or sounds) from a set of audio files and play them (or them) through an arbitrary audio output channel, preferably with audio level control and more or less automatic channel mixing. (this means that several sounds can be played simultaneously in one channel)

The sound should be clear.

The available output channels will be in addition to the default embedded audio added via USB audio devices. For the purposes of this question, "channel" is equivalent to a USB Audio adapter.

In other words, I need to find / write something like:

 -(BOOL) [someObject playContentsOfURL: (NSURL) soundURL  
                            viaChannel: (id) channelspec
                         atVolumeLevel: (double) volume
                                  loop: (BOOL) loop
         ];

      

AVAudioPlayer is very close, but it seems to use built-in stereo audio. I can't figure out how to redirect the output to a specific output device. It works great, though .

The Playback NSSoundDeviceIdentifier is routing to the output device, but the NSSound loop is terrible. If the NSSounds loop wasn't that lousy this would be the winner.

So, if you have an answer to what makes the NSSound loop clean , that answer to that question would be very satisfying.

If you can specify how to provide output routing to the AVAudioPlayer , it will be just as good.

OR , if you can specify or provide CoreAudio or other code that will accomplish this, this might work as well.

+3


source to share





All Articles