Swiftpack.co - yannxou/TapTempoButton as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by yannxou.
yannxou/TapTempoButton 1.0.1
SwiftUI View to easily add tap tempo functionality to music apps.
⭐️ 0
🕓 1 week ago
iOS macOS watchOS tvOS macCatalyst
.package(url: "https://github.com/yannxou/TapTempoButton.git", from: "1.0.1")


A SwiftUI View that easily brings tap tempo functionality to music apps.

How it works

The TapTempoButton takes a content closure so it can be customized. The whole view will handle the tap events automatically and calculate the tempo average (in BPM) which is sent in the onTempoChange closure on each change.

Rather than processing the touch events like a standard Button (on touch up) the view handles them on touch down so the button behaviour is more natural in a musical context.



Add the TapTempoButton to your View and customize it with the content closure.

TapTempoButton(onTempoChange: {
    self.tempo = $0
}) {

It can also be customized like a regular SwiftUI Button:





The following properties can be configured on initialization:

  • tempoRange: Defines the minimum and maximum tempo that can be detected.
  • timeout: Seconds of inactivity after which the ongoing detection will be restarted.
  • minTaps: Minimum number of taps required before sending values to the onTempoChange closure.
  • roundDecimals: Number of decimals to round the BPM to. Set to 0 for integer-only BPM (no decimals). Set to nil to disable rounding.


  1. From the File menu, select Add Packages...
  2. Enter package repository URL: https://github.com/yannxou/TapTempoButton
  3. Confirm the version and let Xcode resolve the package


The idea for this library appeared while working on the app Vetro: Visual Metronome for iOS/macOS. If you like it you can support us by buying any of our apps.


This library is released under the MIT license. See LICENSE for details.


Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 week ago
  • Fixed TouchDown behaviour on macOS
  • Allow using keyboardShortcut

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics