Skip to content

feat: Biking-aware audio enhancement via Core Motion#103

Open
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782177372-biking-audio-enhancement
Open

feat: Biking-aware audio enhancement via Core Motion#103
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782177372-biking-audio-enhancement

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

When Core Motion detects the user is cycling or in automotive motion, the voice recording pipeline automatically improves capture quality to cut through wind noise:

New file: SpeechPipeline/MotionActivityManager — singleton that wraps CMMotionActivityManager, filters for medium/high confidence cycling/automotive activity, and exposes a reactive isBiking flag + Notification.Name.motionBikingStateDidChange. Bootstrapped from AppDelegate.didFinishLaunching. Graceful no-op if Core Motion is unavailable or permission denied — isBiking stays false and the audio pipeline behaves identically to before.

Audio session voice isolation — both recording paths in MessageBox (startRecording AVAudioRecorder path and beginStreamingRecording AVAudioEngine/Deepgram path) now check MotionActivityManager.shared.isBiking when configuring AVAudioSession:

// before:  mode: .default
// after:   mode: isBiking ? .voiceChat : .default

.voiceChat enables Apple's built-in echo cancellation + noise suppression + AGC.

High-pass wind filter — in the streaming STT (AVAudioEngine) path, when biking is detected an AVAudioUnitEQ node configured as a 200 Hz high-pass filter is inserted between inputNode and mainMixerNode. The tap reads from the EQ's output so captured audio is already filtered before reaching Deepgram. The EQ is detached on teardown. No filter is applied when stationary.

Info.plist — added NSMotionUsageDescription for the Core Motion permission prompt.

Link to Devin session: https://app.devin.ai/sessions/d7cfd1e15cbe426387e3f22a9b053796

- Add MotionActivityManager: monitors CMMotionActivityManager for
  cycling/automotive activity, exposes isBiking flag with notification
- When biking detected, auto-switch AVAudioSession to .voiceChat mode
  (enables Apple's noise suppression, echo cancellation, AGC)
- Insert AVAudioUnitEQ high-pass filter at 200 Hz into AVAudioEngine
  graph during streaming STT to cut wind rumble
- Add NSMotionUsageDescription to Info.plist for Core Motion permission
- Graceful fallback: if Core Motion unavailable or denied, audio
  pipeline behaves identically to before

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from API User

Implement motion-aware audio improvements for the Loop iOS app — specifically when the user is biking.

Repository: https://github.com/getathelas/LoopHarness (Swift, SwiftUI, iOS/macOS/visionOS app)

#``# Feature: Biking-Aware Audio Enhancement

#``#``# Goal
When Core Motion detects the user is biking (CMMotionActivityManager → automotive/cycling activity), automatically improve audio capture quality for voice recording / speech-to-text.

#``#``# Implementation

  1. Core Motion detection:

    • Use CMMotionActivityManager to monitor activity transitions
    • Detect .automotive or .cycling activity states
    • Expose a simple reactive flag (e.g. isInMotion / isBiking) that other parts of the app can observe
  2. Voice Isolation auto-enable:

    • When biking is detected, set AVAudioSession category to .playAndRecord with mode .voiceChat
    • Enable Voice Isolation mic mode if available (iOS 16+): AVAudioSession.setMode(.voiceChat) which enables Apple's built-in echo cancellation + noise suppression + auto gain control
    • When motion stops, revert to default audio session settings
  3. High-pass filter via AVAudioEngine:

    • If the app uses AVAudioEngine for audio capture, insert an AVAudioUnitEQ node configured as a high-pass filter at ~150-200Hz to cut wind rumble before the audio is sent to speech recognition
    • Only activate this filter when biking/motion is detected
    • Deactivate when stationary
  4. Graceful fallback:

    • If Core Motion is unavailable or permission denied, default to standard audio session (no crash, no degradation)
    • Log when motion-aware audio is active vs inactive for debugging

#``#``# Notes

  • Look for existing audio session configuration in the codebase and extend it rather than replacing it
  • The app uses voice recording via Action Button → speech-to-text pipeline
  • Keep changes additive and well-documented
  • Add ashbhat as a reviewer on the PR

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
loop-harness Ready Ready Preview, Comment Jun 23, 2026 1:21am

@devin-ai-integration devin-ai-integration Bot requested a review from ashbhat June 23, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants