Skip to content

Instantly share code, notes, and snippets.

@superna9999

superna9999/TapTempo.bash

Last active Mar 19, 2018
Embed
What would you like to do?
#!/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