Nic
Nic

Reputation: 51

how to convert stereo audio to mono?

Nowadays, I'm developing an app for iPhone in which I want to play an audio in left channel and right channel seperately (ps:The audio played is muti-channel), up to now, I have tried many ways, for example, finding some properties(e.g. setPan:) which I can set to do this, but failed,so,what should I do with this problem, could you please give me some suggestions? Thank you very much!

Upvotes: 5

Views: 2495

Answers (3)

luizv
luizv

Reputation: 638

One easy, powerful, free and maintained solution to manipulate audio in iOS is AudioKit. Through it you can create something like this:

leftSignal = AKBooster(input)
leftSignal.rightGain = 0
leftPannedRight = AKPanner(leftSignal, pan: 0.5)

mixer = AKMixer(leftPannedRight)
AudioKit.output = mixer

It's a great solution to audio without the need to deal with low level frameworks. To help you start, there is a lot of tutorials online and answered questions for AudioKit here at StackOverflow. A nice start is with the AudioKit's playgrounds.

Upvotes: 0

Arun
Arun

Reputation: 483

I think Novocaine library will be helpful. You can go through this example.

It'll help you for sure. In example, you can alter following method

- (void)filterData:(float *)data numFrames:(UInt32)numFrames numChannels:(UInt32)numChannels

in NVDSP.mm file to get what you want.

Upvotes: 0

God of Biscuits
God of Biscuits

Reputation: 1338

For manipulating audio at the channel level, see the AVAudioSession class in AVFoundation in the docs that come with Xcode.

In particular, the Audio Session Programming Guide.

Upvotes: 1

Related Questions