TheAmazingAudioEngine / TheAmazingAudioEngine2

The Amazing Audio Engine is a sophisticated framework for iOS audio applications, built so you don't have to.
http://theamazingaudioengine.com/doc2
Other
543 stars 87 forks source link

Input support for macOS #32

Open michaeltyson opened 8 years ago

michaeltyson commented 8 years ago

Currently, there are issues with receiving audio input on macOS, resulting in CannotDoInCurrentContext errors when rendering. I suspect this is related to sample rate, and that an AudioConverter will be required when the input unit's rate doesn't match the output unit's one. This is only a theory, though.

32Beat commented 8 years ago

I frequently got CannotDoInCurrentContext when the renderslice sizes don't match. i.e. if the input device has been set with a 512 frame slicebuffer, then AudioUnitRender will only do 512 frames.

michaeltyson commented 8 years ago

Ah, that's such a dumb error message to use for that case - so unhelpful 😅

Pretty sure the frames per slice is set correctly, though - I did a little digging and sample rate's my best guess so far

32Beat commented 8 years ago

Does the input module actually attach an input device to the audio unit?

32Beat commented 8 years ago

line 95:

#if !TARGET_OS_IPHONE
    NSAssert(!(self.outputEnabled && self.inputEnabled), @"Can only have both input and output enabled on iOS");
#endif

should probably change to something like:

#if !TARGET_OS_IPHONE
    NSAssert(!(self.outputEnabled ^ self.inputEnabled), @"Must have either output or input enabled, (but not both)");
#endif

having both input and output enabled on the desktop didn't work for me. Likely not possible as the input will be running in its own thread.

32Beat commented 8 years ago

https://github.com/32Beat/TAAE2/tree/MacOS_InputModule