agentleFS
ai-enhanced-engineerai-enhanced-engineer/aiee-skills/skills/ios-audio-haptics/SKILL.md

ios-audio-haptics

Skill4 starsChanged 5 months agoMITView on GitHub

AVFoundation audio and Core Haptics for guided breathing apps. Audio sessions, mixing, interruption handling, and haptic pattern design for iOS and watchOS. Use when implementing audio playback, multi-track mixing, audio interruption handling, or haptic feedback patterns.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add audio to UIBackgroundModes in Info.plist.

    line 35

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

iOS Audio & Haptics

Audio playback (AVFoundation) and haptic feedback (Core Haptics / WKHapticType) patterns for guided breathing and wellness apps.

When to Use

  • Playing ambient sounds or voice guidance during breathing sessions
  • Mixing multiple audio sources (ambient + voice)
  • Handling audio interruptions (calls, Siri, other apps)
  • Designing haptic patterns for breathing rhythm cues

Core Concepts

Audio Session Configuration

Configure AVAudioSession with .playback category for background audio. Use .duckOthers option (implies mixWithOthers) for ambient layering. Set up AVAudioEngine with separate player nodes for ambient and guidance tracks.

Audio Mixing

Attach multiple AVAudioPlayerNode instances to AVAudioEngine via separate AVAudioMixerNode nodes. Control volume per channel (e.g., ambient at 0.3, guidance at 1.0). Loop ambient audio by re-scheduling in the completion handler.

Core Haptics (iOS)

CHHapticEngine provides rich parametric haptics. Check capabilitiesForHardware().supportsHaptics before use. Use intensity curves that rise during inhale and fall during exhale. Set stoppedHandler to auto-restart the engine. Use low sharpness (0.1-0.2) for calming breath cues.

watchOS Haptics

WKHapticType is simpler than Core Haptics. Map breath phases to built-in types: .start for inhale, .click for hold, .directionDown for exhale, .stop for rest. No continuous patterns available -- discrete events only.

Background Audio

Add audio to UIBackgroundModes in Info.plist. Without this, audio stops when the app enters background. Required for any breathing session that continues with the screen off.

Audio Format Recommendations

Use CaseFormatBitrateNotes
Ambient sounds (loops)AAC (.m4a)128kbpsGood compression, loops well
Voice guidanceAAC (.m4a)96kbpsSpeech doesn't need high bitrate
Short UI soundsCAF (.caf)UncompressedLow latency playback
Streaming from AI TTSPCM bufferN/AFeed directly to AVAudioPlayerNode

Anti-Patterns

Anti-PatternPattern
Not handling audio interruptionsAudio sessions can be interrupted by calls/Siri; observe interruptionNotification to handle gracefully
Using AVAudioPlayer for mixingUse AVAudioEngine with player nodes
Playing haptics without checking capabilityCheck CHHapticEngine.capabilitiesForHardware()
Continuous haptics during hold phaseSilence during hold -- cognitive rest for user
Background audio without UIBackgroundModesAdd audio to background modes in Info.plist

Key References

See reference.md for detailed explanations of audio session categories, interruption handling, haptic engine lifecycle, and pattern design principles.

See examples.md for complete Swift and Info.plist implementations.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.