Skip to content

thegridbase-ai/Haptic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Haptic - Pro Metronome for iOS & watchOS

A professional-grade metronome with CoreHaptics and uninterruptible Apple Watch background execution. Designed for progressive metal guitarists who need sharp, tactile cues.

Swift SwiftUI iOS watchOS

🌐 Web Demo: haptic.thegridbase.com


Features

  • Uninterrupted Watch Haptics - Uses HKWorkoutSession to keep vibrating even when wrist is lowered
  • High-Precision Timing - DispatchSourceTimer prevents drift during long sessions
  • CoreHaptics Transient Patterns - Sharp, percussive taps (not generic vibrations)
  • Prog-Metal Ready - 7/8, 11/8, 13/16 and custom accent patterns
  • iPhone ↔ Watch Sync - Real-time BPM synchronization
  • Digital Crown - Adjust BPM by rotating the crown

Setup Instructions

1. Create Xcode Project

  1. Open Xcode 15+
  2. File β†’ New β†’ Project
  3. Select "iOS App" with Watch App companion
  4. Configure:
    • Product Name: Haptic
    • Team: Your Apple Developer Team
    • Organization Identifier: com.yourname
    • Interface: SwiftUI
    • Language: Swift
    • βœ… Include Watch App (with Watch App for watchOS 10)

2. Copy Source Files

Replace the generated files with the files from this repository:

Haptic/                    β†’ Your Xcode project's main target
HapticWatch Extension/     β†’ Your Xcode project's watch extension

3. Configure Capabilities

iOS Target:

  1. Select iOS target β†’ Signing & Capabilities
  2. Add: HealthKit (for workout session sync awareness)
  3. Add: Background Modes β†’ βœ… Audio, AirPlay, and Picture in Picture

watchOS Target:

  1. Select Watch target β†’ Signing & Capabilities
  2. Add: HealthKit
  3. Add: Background Modes β†’ βœ… Workout processing

4. Info.plist Entries

iOS Info.plist:

<key>NSHealthShareUsageDescription</key>
<string>Haptic uses HealthKit to maintain metronome sync with Apple Watch during workouts.</string>

watchOS Info.plist:

<key>NSHealthShareUsageDescription</key>
<string>Haptic needs workout access to keep the metronome running in background.</string>
<key>WKBackgroundModes</key>
<array>
    <string>workout-processing</string>
</array>

5. Build & Run

⚠️ IMPORTANT: You MUST test on physical devices!

  • CoreHaptics doesn't work on Simulator
  • Watch background mode requires real hardware
  • Use your iPhone + Apple Watch pair

Testing Checklist

iPhone App

  • BPM display shows correctly
  • Tap BPM number for tap tempo
  • +1/-1/+10/-10 buttons work
  • Beat sequencer shows correct number of beats
  • Tap beats to toggle accent (blue dot appears)
  • Time signature picker opens
  • Play button starts metronome
  • Current beat highlights green/blue
  • Haptic feedback on each beat

Apple Watch App

  • BPM syncs from iPhone
  • Digital Crown adjusts BPM
  • Play/Stop works
  • Beat indicators pulse
  • CRITICAL: Lower wrist - haptics should CONTINUE
  • CRITICAL: Turn screen off - haptics should CONTINUE
  • Workout icon appears when playing (HKWorkoutSession active)

Sync Test

  • Change BPM on iPhone β†’ Watch updates
  • Change BPM on Watch β†’ iPhone updates
  • Start on iPhone β†’ Watch shows playing state
  • Stop on Watch β†’ iPhone shows stopped state

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         iPhone                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  MetronomeView (SwiftUI)                                    β”‚
β”‚       ↓                                                      β”‚
β”‚  MetronomeManager (Timing Engine)                           β”‚
β”‚       ↓                                                      β”‚
β”‚  HapticEngine (CoreHaptics)                                 β”‚
β”‚       ↓                                                      β”‚
β”‚  WatchSyncManager ←──── WCSession ────→ Watch               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       Apple Watch                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  WatchMetronomeView (SwiftUI)                               β”‚
β”‚       ↓                                                      β”‚
β”‚  WorkoutSessionManager (HKWorkoutSession)                   β”‚
β”‚       ↓ Keeps app alive in background                       β”‚
β”‚  MetronomeManager (Timing Engine)                           β”‚
β”‚       ↓                                                      β”‚
β”‚  HapticEngine (CoreHaptics / WKInterfaceDevice fallback)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Troubleshooting

Haptics stop when wrist is lowered

  • Ensure WorkoutSession is starting (check for workout icon)
  • Verify HealthKit authorization was granted
  • Check Background Modes capability includes "workout-processing"

Watch not connecting

  • Both devices must be on same iCloud account
  • Watch must be paired with iPhone
  • Try: Settings β†’ General β†’ Reset β†’ Reset Sync Data

Timing drift

  • This shouldn't happen (we use mach_absolute_time)
  • If it does, check CPU throttling on device

License

MIT License - Use freely for your projects.


Author

Can Kilic

About

Pro metronome for progressive metal - iOS, watchOS & Web

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors