Talking to someone through an AIR app sounds simple: microphone in, speaker out, send the audio over the network. In practice it fails the moment both sides talk at once, or the moment the two devices are in the same room. You hear yourself, delayed. Or the devices start to howl.
What's missing is acoustic echo cancellation (AEC): the device has to remove its own loudspeaker sound from what its microphone picks up. Every phone call and video call app does this. AIR doesn't.
Why AIR's own microphone isn't enough
Microphone.getEnhancedMicrophone()was AIR's answer on the desktop years ago. On iOS and Android it doesn't give you a working, full-duplex echo canceller.- AIR's microphone and AIR's sound output are two separate things. The operating system's echo canceller only works when capture and playback run in the same voice session, so the canceller knows exactly what the speaker is playing.
- Speex and Nellymoser, the codecs AIR offers, belong to another era. Modern voice uses Opus.
What it actually takes
We built two-way voice into KlugMedia, our native media extension, and it runs in our own published apps every day. These are the parts:
- One native voice session per app. On iOS and macOS that is Apple's Voice Processing I/O unit, the same echo canceller FaceTime uses. On Android we use WebRTC's AEC3 echo canceller, compiled into the extension for all four Android architectures. Capture, playback and echo cancellation live in one place.
- Opus encoding and decoding in native code, at low bitrate and low delay.
- Transport over your existing RTMP connection. The Opus packets travel as
NetStream.send()data messages next to the video. Any RTMP server that forwards stream data messages to subscribers can carry the voice; our streaming server does it out of the box. No WebRTC stack, no second connection. - An adaptive jitter buffer that rides out Wi-Fi hiccups and then returns to low delay by itself.
The rule that explains most voice bugs: one capture per process
The most important lesson from production: there must be exactly one audio capture in the app.
If anything else opens the microphone while the native voice session is running, even AIR's own Microphone class, it reconfigures the shared audio session. On iOS the echo canceller then degrades silently, or the session can't be recovered at runtime. It also works the other way round: a screen that needs the AIR microphone (for example a level meter) has to wait until the native session is fully stopped.
That is why voice can't be an add-on next to AIR's audio. It has to own the audio.
Same-room feedback
Echo cancellation removes the echo of the remote voice. When both devices are in the same room, the microphone of one device also picks up the speaker of the other, a loop that no single device can see. We handle it with a guard that detects the howl and dampens it, and with a one-time hint in the app: test the two devices in separate rooms.
What you get as an AIR developer
// video: one native session, H.264 over RTMP media.startPublish( "rtmp://your.server:1935/live", "camera-1" ); // voice: native Opus with the platform's echo canceller var voice:OpusVoiceBridge = new OpusVoiceBridge( new NativeOpusCodec(), 48000, 1, 960 );
The full voice setup, including the transport, is in the KlugMedia documentation.
No microphone class, no codec juggling, no audio session code in ActionScript. At the time of writing we know of no other AIR native extension that offers two-way voice with echo cancellation: the large catalogues stop at audio recording and media playback.
KlugMedia: camera, H.264 video and two-way voice with echo cancellation for Adobe AIR on iOS, Android, macOS and Windows. klughomesolutions.com/klugmedia.html
More articles
- Shipping an AIR app to the Mac App Store and TestFlight
- Why AIR native extensions don't need a package manager
- One app, many native extensions – and they have to work together
- Camera and H.264 live streaming in Adobe AIR, without AIR's camera
- Sign in with Apple and Google in an Adobe AIR app
- Adobe AIR on iOS 27: the launch crash and how to ship anyway
- A distriqt alternative for Adobe AIR native extensions