(OSX/Cocoa)
I need to be able to take any sound (or sounds) from a collection of sound files and play it (or them) through an arbitrary sound output channel, preferably with per-sound level control and more-or-less automatic channel mixing. (meaning that multiple sounds can play simultaneously in the same channel)
The sound must be capable of being looped cleanly.
The available output channels would be in addition to the default built-in audio, added via USB audio devices. For the purposes of this question a "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 appears to assume the use of the built-in stereo audio. I cannot figure out how to route the output to a particular output device. It loops great, however.
NSSound's playbackDeviceIdentifier does the output device routing part, but NSSound's looping is terrible. If NSSounds looping wasn't so lousy, it would be a winner.
So if you have an answer for making NSSound loop cleanly, that would answer this question very satisfactorily.
If you can specify how to provide output routing to AVAudioPlayer, that would be equally nifty.
OR, if you can point to or provide CoreAudio or other code that will accomplish this, that could work also.