|
| 1 | +# PlatformAudio |
| 2 | + |
| 3 | +These examples demonstrate the platform Audio Device Module path: |
| 4 | + |
| 5 | +- `PlatformAudioSender`: publishes microphone audio with echo cancellation, noise suppression, and auto gain control. |
| 6 | +- `PlatformAudioPlayer`: joins the same room and plays subscribed remote audio through the platform output device. |
| 7 | + |
| 8 | +Build the collection, then run the player and sender with different participant tokens for the same room: |
| 9 | + |
| 10 | +```bash |
| 11 | +./build/platform_audio/player/PlatformAudioPlayer <ws-url> <player-token> |
| 12 | +./build/platform_audio/sender/PlatformAudioSender <ws-url> <sender-token> |
| 13 | +``` |
| 14 | + |
| 15 | +Environment fallbacks: |
| 16 | + |
| 17 | +```bash |
| 18 | +export LIVEKIT_URL=wss://your-livekit-host |
| 19 | +export LIVEKIT_PLAYER_TOKEN=<player-token> |
| 20 | +export LIVEKIT_SENDER_TOKEN=<sender-token> |
| 21 | +``` |
| 22 | + |
| 23 | +## Test environments |
| 24 | + |
| 25 | +The sender captures the mic and runs the AEC/NS/AGC front-end; the player drives |
| 26 | +hardware playout. The acoustic echo cancellation (AEC) reference is per Audio |
| 27 | +Device Module (ADM), so the sender can only cancel playout from *its own* ADM. |
| 28 | +Pick an environment based on what you want to prove out. |
| 29 | + |
| 30 | +| Environment | What it proves | Notes | |
| 31 | +|-------------|----------------|-------| |
| 32 | +| **Two machines** (sender on A, player on B) | End-to-end capture → publish → subscribe → hardware playout over the network, like a real call. | Closest to a real LiveKit call. For full duplex (both apps on both boxes), use headphones or separate rooms to avoid feedback. | |
| 33 | +| **One machine + headphones** | Mic capture and ADM playout both work on one box, with no acoustic feedback path. | Best for confirming device selection and round-trip latency in isolation. | |
| 34 | +| **Noise suppression (NS)** | Steady background noise is attenuated while speech passes. | Add a fan / AC hum / typing near the mic. A/B by setting `noise_suppression = false` in `sender/main.cpp`. | |
| 35 | +| **Auto gain control (AGC)** | Quiet vs. loud / near vs. far speech is normalized on the player side. | A/B by setting `auto_gain_control = false` in `sender/main.cpp`. | |
| 36 | +| **`prefer_hardware = true`** | Platform hardware voice processing engages (e.g. macOS voice-processing I/O). | Set in the sender options; compare CPU and audio character vs. the software path. | |
| 37 | +| **Device / hot-plug sanity** | `recordingDevices()` / `playoutDevices()` reflect attached hardware and route correctly. | Plug/unplug a USB or Bluetooth mic/headset before launch and check the startup device logs. | |
| 38 | + |
| 39 | +> **AEC caveat:** these split sender/player apps cannot demonstrate AEC against |
| 40 | +> each other on one machine over open speakers — the sender's AEC has no |
| 41 | +> reference to the player's separate ADM, so the speaker output is treated as |
| 42 | +> external sound and you get an echo/feedback loop. Genuine AEC requires a |
| 43 | +> single application that both plays remote audio and captures the mic through |
| 44 | +> the *same* ADM. Use headphones to avoid feedback with these examples. |
0 commit comments