alexbw / novocaine

Painless high-performance audio on iOS and Mac OS X
http://alexbw.github.com/novocaine/
MIT License
2.23k stars 274 forks source link

Option to make play in mono #29

Closed pec1985 closed 12 years ago

pec1985 commented 12 years ago

This might sound silly, but I would find it useful to make the sound, music, play in mono sound. Can this be done in the setOutputBlock?

alexbw commented 12 years ago

You can copy your sound twice into the output data. That's probably the fastest. I had plans once to allow for more fine-tuned control of the channel structure, but I ran out of free time.

On Tuesday, August 14, 2012 at 9:27 PM, pec1985 wrote:

This might sound silly, but I would find it useful to make the sound, music, play in mono sound. Can this be done in the setOutputBlock?

— Reply to this email directly or view it on GitHub (https://github.com/alexbw/novocaine/issues/29).

pec1985 commented 12 years ago

I'm sorry, I don't understand. You make it sound very simple, and if I'm not asking too much, could provide a example on how to copy the sound twice to the output data? Or at least, a hint, where in code could I do this?

Thanks.

morganpackard commented 12 years ago

I'd say that Novocaine is meant to be the simplest possible way in and out of the hardware, and modifying it to mix a stereo signal down to mono is outside the mission of Novocaine, which is to remove the pain of configuring the Core Audio framework. Where is your audio coming from? If you're interested in working with audio at the sample level, which is what Novocaine is for, doing learning how to mix a stereo signal down to mono should be something you're comfortable doing on your own, and it may be time to study up on some fundamentals of low-level digital audio.

alexbw commented 12 years ago

Thanks Morgan, you said it perfectly.

pec1985, one solution here is a for loop over all of your samples like this

for (int i=0; i < numChannels*numFrames; i+=numChannels) { for (int j=i; j < i+numChannels; ++j) { data[j] = yourAudio[i]; } }

But Morgan's right, the purpose of Novocaine is to be able to get to working with samples quickly, and folks here won't always be able to provide you with a direct answer. Separate projects (like NVDSP, or perhaps unannounced synthesis libraries) can help you manipulate the samples.

On Aug 15, 2012, at 9:27 AM, Morgan Packard wrote:

I'd say that Novocaine is meant to be the simplest possible way in and out of the hardware, and modifying it to mix a stereo signal down to mono is outside the mission of Novocaine, which is to remove the pain of configuring the Core Audio framework. Where is your audio coming from? If you're interested in working with audio at the sample level, which is what Novocaine is for, doing learning how to mix a stereo signal down to mono should be something you're comfortable doing on your own, and it may be time to study up on some fundamentals of low-level digital audio.

— Reply to this email directly or view it on GitHub.

pec1985 commented 12 years ago

Thanks guys, learning CoreAudio, and all the related frameworks and libraries, is what I'm trying to do. I will keep researching and definitely give that loop a try.

Closing as this is out of the scope of the project.

morganpackard commented 12 years ago

It's one thing to learn the frameworks and the libraries, and another thing to learn how to deal with buffers of raw audio data. You can do quite a lot with core audio without ever touching raw audio data. But that's not really what Novocaine is about.