Skip to content

Instantly share code, notes, and snippets.

@superna9999
Last active March 19, 2018 19:58
Show Gist options
  • Save superna9999/ff0352698d73bff54a24b21871995b73 to your computer and use it in GitHub Desktop.
Save superna9999/ff0352698d73bff54a24b21871995b73 to your computer and use it in GitHub Desktop.
#!/bin/bash
# SPDX-License-Identifier: WTFPL
# Copyright © 2018 Neil "Superna" Armstrong
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See the COPYING file or http://www.wtfpl.net/
# for more details.
PREV="$(date +%s%N | cut -b1-13)"
TAPS="0"
COUNT="0"
while read -p "tapTempo : press any key (CTRL+D for quit)" tap ; do
CUR="$(date +%s%N | cut -b1-13)"
TAPS="$TAPS + $(($CUR-$PREV))"
PREV=$CUR
COUNT="$(($COUNT + 1))"
done
echo ""
echo BPM : $((60000 / $(($(($TAPS + 0)) / $COUNT))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment